# | Line 187 | Line 187 | void VectorTestCase::testAccessEntries(){ | |
---|---|---|
187 | ||
188 | void VectorTestCase::testAccessEntries(){ | |
189 | //test [] operator | |
190 | – | CPPUNIT_ASSERT(zero[0] == 0.0); |
191 | – | CPPUNIT_ASSERT(one[0] == 1.0); |
192 | – | CPPUNIT_ASSERT(v3[0] == 4.0); |
190 | ||
191 | + | CPPUNIT_ASSERT_DOUBLES_EQUAL(zero[0], 0.0, oopse::epsilon); |
192 | + | CPPUNIT_ASSERT_DOUBLES_EQUAL(one[0] , 1.0, oopse::epsilon); |
193 | + | CPPUNIT_ASSERT_DOUBLES_EQUAL(v3[0] , 4.0, oopse::epsilon); |
194 | //test () operator | |
195 | < | CPPUNIT_ASSERT(v3(0) != 1.0); |
195 | > | CPPUNIT_ASSERT_DOUBLES_EQUAL(v3(0) , 4.0, oopse::epsilon); |
196 | ||
197 | + | Vec4 a1; |
198 | + | double *pa1 = a1.getArrayPointer(); |
199 | + | |
200 | + | pa1[0] = 4.0; |
201 | + | pa1[1] = 1.0; |
202 | + | pa1[2] = 3.0; |
203 | + | pa1[3] = 2.0; |
204 | + | |
205 | + | CPPUNIT_ASSERT(a1 == v3); |
206 | } | |
207 | ||
208 | void VectorTestCase::testOtherMemberFunctions(){ | |
209 | //test length() | |
210 | < | CPPUNIT_ASSERT(zero.length() == 0.0); |
211 | < | CPPUNIT_ASSERT(one.length() == 2.0); |
212 | < | CPPUNIT_ASSERT(v2.length() == sqrt(14.0)); |
210 | > | CPPUNIT_ASSERT_DOUBLES_EQUAL(zero.length(), 0.0, oopse::epsilon); |
211 | > | CPPUNIT_ASSERT_DOUBLES_EQUAL(one.length(), 2.0, oopse::epsilon); |
212 | > | CPPUNIT_ASSERT_DOUBLES_EQUAL(v2.length(), sqrt(14.0), oopse::epsilon); |
213 | ||
214 | //test lengthSquare() | |
215 | < | CPPUNIT_ASSERT(zero.lengthSquare() == 0.0); |
216 | < | CPPUNIT_ASSERT(one.lengthSquare() == 4.0); |
217 | < | CPPUNIT_ASSERT(v2.length() == 14.0); |
215 | > | CPPUNIT_ASSERT_DOUBLES_EQUAL(zero.lengthSquare(), 0.0, oopse::epsilon); |
216 | > | CPPUNIT_ASSERT_DOUBLES_EQUAL(one.lengthSquare(), 4.0, oopse::epsilon); |
217 | > | CPPUNIT_ASSERT_DOUBLES_EQUAL(v2.lengthSquare(), 14.0, oopse::epsilon); |
218 | ||
219 | //test normalize() | |
220 | Vec4 a1 = one; | |
# | Line 223 | Line 232 | void VectorTestCase::testOtherTemplateFunctions(){ | |
232 | } | |
233 | void VectorTestCase::testOtherTemplateFunctions(){ | |
234 | //test dot | |
235 | < | CPPUNIT_ASSERT(dot(one, two) == 8.0); |
236 | < | CPPUNIT_ASSERT(dot(v1, v3) == 20.0); |
235 | > | CPPUNIT_ASSERT_DOUBLES_EQUAL(dot(one, two), 8.0, oopse::epsilon); |
236 | > | CPPUNIT_ASSERT_DOUBLES_EQUAL(dot(v1, v3), 20.0, oopse::epsilon); |
237 | ||
238 | //test distance | |
239 | < | CPPUNIT_ASSERT(distance(one, two) == 2.0); |
240 | < | CPPUNIT_ASSERT(distance(v1, v2) == sqrt(56.0)); |
239 | > | CPPUNIT_ASSERT_DOUBLES_EQUAL(distance(one, two), 2.0, oopse::epsilon); |
240 | > | CPPUNIT_ASSERT_DOUBLES_EQUAL(distance(v1, v2), sqrt(56.0), oopse::epsilon); |
241 | ||
242 | //test distanceSquare | |
243 | < | CPPUNIT_ASSERT(distanceSquare(one, two) == 4.0); |
244 | < | CPPUNIT_ASSERT(distanceSquare(v1, v2) == 56); |
243 | > | CPPUNIT_ASSERT_DOUBLES_EQUAL(distanceSquare(one, two), 4.0, oopse::epsilon); |
244 | > | CPPUNIT_ASSERT_DOUBLES_EQUAL(distanceSquare(v1, v2), 56, oopse::epsilon); |
245 | ||
246 | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |