| 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 |
|
} |
| 198 |
|
|
| 199 |
|
void VectorTestCase::testOtherMemberFunctions(){ |
| 200 |
|
//test length() |
| 201 |
< |
CPPUNIT_ASSERT(zero.length() == 0.0); |
| 202 |
< |
CPPUNIT_ASSERT(one.length() == 2.0); |
| 203 |
< |
CPPUNIT_ASSERT(v2.length() == sqrt(14.0)); |
| 201 |
> |
CPPUNIT_ASSERT_DOUBLES_EQUAL(zero.length(), 0.0, oopse::epsilon); |
| 202 |
> |
CPPUNIT_ASSERT_DOUBLES_EQUAL(one.length(), 2.0, oopse::epsilon); |
| 203 |
> |
CPPUNIT_ASSERT_DOUBLES_EQUAL(v2.length(), sqrt(14.0), oopse::epsilon); |
| 204 |
|
|
| 205 |
|
//test lengthSquare() |
| 206 |
< |
CPPUNIT_ASSERT(zero.lengthSquare() == 0.0); |
| 207 |
< |
CPPUNIT_ASSERT(one.lengthSquare() == 4.0); |
| 208 |
< |
CPPUNIT_ASSERT(v2.length() == 14.0); |
| 206 |
> |
CPPUNIT_ASSERT_DOUBLES_EQUAL(zero.lengthSquare(), 0.0, oopse::epsilon); |
| 207 |
> |
CPPUNIT_ASSERT_DOUBLES_EQUAL(one.lengthSquare(), 4.0, oopse::epsilon); |
| 208 |
> |
CPPUNIT_ASSERT_DOUBLES_EQUAL(v2.lengthSquare(), 14.0, oopse::epsilon); |
| 209 |
|
|
| 210 |
|
//test normalize() |
| 211 |
|
Vec4 a1 = one; |
| 223 |
|
} |
| 224 |
|
void VectorTestCase::testOtherTemplateFunctions(){ |
| 225 |
|
//test dot |
| 226 |
< |
CPPUNIT_ASSERT(dot(one, two) == 8.0); |
| 227 |
< |
CPPUNIT_ASSERT(dot(v1, v3) == 20.0); |
| 226 |
> |
CPPUNIT_ASSERT_DOUBLES_EQUAL(dot(one, two), 8.0, oopse::epsilon); |
| 227 |
> |
CPPUNIT_ASSERT_DOUBLES_EQUAL(dot(v1, v3), 20.0, oopse::epsilon); |
| 228 |
|
|
| 229 |
|
//test distance |
| 230 |
< |
CPPUNIT_ASSERT(distance(one, two) == 2.0); |
| 231 |
< |
CPPUNIT_ASSERT(distance(v1, v2) == sqrt(56.0)); |
| 230 |
> |
CPPUNIT_ASSERT_DOUBLES_EQUAL(distance(one, two), 2.0, oopse::epsilon); |
| 231 |
> |
CPPUNIT_ASSERT_DOUBLES_EQUAL(distance(v1, v2), sqrt(56.0), oopse::epsilon); |
| 232 |
|
|
| 233 |
|
//test distanceSquare |
| 234 |
< |
CPPUNIT_ASSERT(distanceSquare(one, two) == 4.0); |
| 235 |
< |
CPPUNIT_ASSERT(distanceSquare(v1, v2) == 56); |
| 234 |
> |
CPPUNIT_ASSERT_DOUBLES_EQUAL(distanceSquare(one, two), 4.0, oopse::epsilon); |
| 235 |
> |
CPPUNIT_ASSERT_DOUBLES_EQUAL(distanceSquare(v1, v2), 56, oopse::epsilon); |
| 236 |
|
|
| 237 |
|
} |