ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/test/math/Vector3TestCase.cpp
(Generate patch)

Comparing trunk/OOPSE-3.0/test/math/Vector3TestCase.cpp (file contents):
Revision 1593 by tim, Mon Oct 18 21:03:15 2004 UTC vs.
Revision 1644 by tim, Mon Oct 25 22:46:19 2004 UTC

# Line 5 | Line 5 | void Vector3TestCase::setUp(){
5  
6  
7   void Vector3TestCase::setUp(){
8 +    zero[0] = 0.0;
9 +    zero[1] = 0.0;
10 +    zero[2] = 0.0;
11 +
12 +    one[0] = 1.0;
13 +    one[1] = 1.0;
14 +    one[2] = 1.0;
15 +
16 +    two[0] = 2.0;
17 +    two[1] = 2.0;
18 +    two[2] = 2.0;
19 +
20 +    v1[0] = 1.0;
21 +    v1[1] = 2.0;
22 +    v1[2] = 3.0;
23 +
24 +    v2[0] = 4.0;
25 +    v2[1] = 1.0;
26 +    v2[2] = 2.0;
27 +
28 +    v3[0] = 1.0;
29 +    v3[1] = 10.0;
30 +    v3[2] = -7.0;
31 +
32 +    
33   }
34  
35   void Vector3TestCase::tearDown(){
36   }
37  
38   void Vector3TestCase::testConstructors(){
39 +    double b[] = {2.9, 3.2, 1.2};
40 +    Vector3d v(b);
41 +    CPPUNIT_ASSERT_DOUBLES_EQUAL(v.x(), 2.9, oopse::epsilon);
42 +    CPPUNIT_ASSERT_DOUBLES_EQUAL(v.y(), 3.2, oopse::epsilon);
43 +    CPPUNIT_ASSERT_DOUBLES_EQUAL(v.z(), 1.2, oopse::epsilon);    
44   }
45  
46   void Vector3TestCase::testArithmetic(){
47 +
48 +    
49   }
50  
51   void Vector3TestCase::testOperators(){
52 +    Vector3d tmp;
53 +    //test +=
54 +
55 +    //test +
56 +    CPPUNIT_ASSERT(one + one == two);
57 +    
58 +    //test -=
59 +    tmp = two;
60 +    tmp -= one;
61 +    CPPUNIT_ASSERT(tmp == one);
62 +    
63 +    //test -
64 +    CPPUNIT_ASSERT(two -one == one);
65 +    
66 +    //test *=
67 +    tmp = two;
68 +    tmp *= 0.5;
69 +    CPPUNIT_ASSERT(tmp == one);
70 +    
71 +    //test *
72 +    CPPUNIT_ASSERT(two * 0.5 == one);
73 +    CPPUNIT_ASSERT(0.5 * two == one);
74 +
75 +    //test /=
76 +    tmp = two;
77 +    tmp *= 2.0;
78 +    CPPUNIT_ASSERT(tmp == one * 4.0);    
79 +    
80 +    //test /
81 +    CPPUNIT_ASSERT( two /2.0 == one);
82 +    CPPUNIT_ASSERT( two /4.0 == one * 0.5);
83 +
84   }
85  
86   void Vector3TestCase::testAccessEntries(){
23 }
87  
88 < void Vector3TestCase::testOtherTemplateFunctions(){        
88 >    CPPUNIT_ASSERT_DOUBLES_EQUAL(v1.z(), 3.0, oopse::epsilon);
89 >    CPPUNIT_ASSERT_DOUBLES_EQUAL(v2.x(), 4.0, oopse::epsilon);
90 >    CPPUNIT_ASSERT_DOUBLES_EQUAL(v3.y(), 10.0, oopse::epsilon);
91  
92 < }
92 >    Vector3d tmp;
93 >    tmp.x() = 78.01;
94 >    tmp.y() = 21.0;
95 >    tmp.z() =133.12;
96 >    CPPUNIT_ASSERT_DOUBLES_EQUAL(tmp.x(), 78.01, oopse::epsilon);
97 >    CPPUNIT_ASSERT_DOUBLES_EQUAL(tmp.y(), 21.0, oopse::epsilon);
98 >    CPPUNIT_ASSERT_DOUBLES_EQUAL(tmp.z(), 133.12, oopse::epsilon);
99 >
100 > }
101 >
102 > void Vector3TestCase::testOtherTemplateFunctions(){      
103 >    //test cross
104 >    CPPUNIT_ASSERT(cross(v1, v2) == v3);
105 >    CPPUNIT_ASSERT(cross(one, two) == zero);
106 >    
107 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines