ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/test/math/Vector3TestCase.cpp
Revision: 1603
Committed: Tue Oct 19 21:28:55 2004 UTC (19 years, 8 months ago) by tim
File size: 1945 byte(s)
Log Message:
more bugs get fixed at math library

File Contents

# User Rev Content
1 tim 1593 #include "math/Vector3TestCase.hpp"
2    
3     // Registers the fixture into the 'registry'
4     CPPUNIT_TEST_SUITE_REGISTRATION( Vector3TestCase );
5    
6    
7     void Vector3TestCase::setUp(){
8 tim 1595 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 tim 1593 }
34    
35     void Vector3TestCase::tearDown(){
36     }
37    
38     void Vector3TestCase::testConstructors(){
39     }
40    
41     void Vector3TestCase::testArithmetic(){
42 tim 1595
43    
44 tim 1593 }
45    
46     void Vector3TestCase::testOperators(){
47 tim 1595 Vector3d tmp;
48     //test +=
49    
50     //test +
51     CPPUNIT_ASSERT(one + one == two);
52    
53     //test -=
54     tmp = two;
55     tmp -= one;
56     CPPUNIT_ASSERT(tmp == one);
57    
58     //test -
59     CPPUNIT_ASSERT(two -one == one);
60    
61     //test *=
62     tmp = two;
63     tmp *= 0.5;
64     CPPUNIT_ASSERT(tmp == one);
65    
66     //test *
67     CPPUNIT_ASSERT(two * 0.5 == one);
68     CPPUNIT_ASSERT(0.5 * two == one);
69    
70     //test /=
71     tmp = two;
72     tmp *= 2.0;
73 tim 1603 CPPUNIT_ASSERT(tmp == one * 4.0);
74    
75 tim 1595 //test /
76 tim 1603 CPPUNIT_ASSERT( two /2.0 == one);
77     CPPUNIT_ASSERT( two /4.0 == one * 0.5);
78    
79 tim 1593 }
80    
81     void Vector3TestCase::testAccessEntries(){
82 tim 1595
83 tim 1603 CPPUNIT_ASSERT_DOUBLES_EQUAL(v1.z(), 3.0, oopse::epsilon);
84     CPPUNIT_ASSERT_DOUBLES_EQUAL(v2.x(), 4.0, oopse::epsilon);
85     CPPUNIT_ASSERT_DOUBLES_EQUAL(v3.y(), 10.0, oopse::epsilon);
86 tim 1595
87     Vector3d tmp;
88     tmp.x() = 78.01;
89     tmp.y() = 21.0;
90     tmp.z() =133.12;
91 tim 1603 CPPUNIT_ASSERT_DOUBLES_EQUAL(tmp.x(), 78.01, oopse::epsilon);
92     CPPUNIT_ASSERT_DOUBLES_EQUAL(tmp.y(), 21.0, oopse::epsilon);
93     CPPUNIT_ASSERT_DOUBLES_EQUAL(tmp.z(), 133.12, oopse::epsilon);
94    
95 tim 1593 }
96    
97 tim 1595 void Vector3TestCase::testOtherTemplateFunctions(){
98     //test cross
99     CPPUNIT_ASSERT(cross(v1, v2) == v3);
100     CPPUNIT_ASSERT(cross(one, two) == zero);
101    
102     }