01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.testutil;
04:
05: import junit.framework.TestCase;
06:
07: public class CartesianVectorTest extends TestCase {
08: public void testParseVector() throws Exception {
09: CartesianVector v = CartesianVector.parse("(0,0)");
10: assertEquals(0.0, v.getX(), .001);
11: assertEquals(0.0, v.getY(), .001);
12: }
13:
14: public void testVectorEquals() throws Exception {
15: CartesianVector v1 = new CartesianVector(3.1, -5.2);
16: CartesianVector v2 = new CartesianVector(3.1, -5.2);
17: CartesianVector v3 = new CartesianVector(0, 0);
18: assertTrue(v1.equals(v2));
19: assertFalse(v1.equals(v3));
20: }
21:
22: public void testAdd() throws Exception {
23: CartesianVector v1 = new CartesianVector(3, 4);
24: CartesianVector v2 = new CartesianVector(1, 2);
25: CartesianVector sum = v1.add(v2);
26: assertEquals(sum, new CartesianVector(4, 6));
27: }
28: }
|