| 167 |
|
//test mul |
| 168 |
|
Vec4 a6; |
| 169 |
|
a6 = one; |
| 170 |
< |
a6.mul(2.0); |
| 170 |
> |
a6 *= 2.0; |
| 171 |
|
CPPUNIT_ASSERT( a6 == two); |
| 172 |
|
|
| 173 |
|
Vec4 a7; |
| 174 |
< |
a7.mul(one, 2.0); |
| 174 |
> |
a7 = one * 2.0; |
| 175 |
|
CPPUNIT_ASSERT( a7 == two); |
| 176 |
< |
Vec4 a8; |
| 177 |
< |
a7.mul(zero, 2.0); |
| 178 |
< |
CPPUNIT_ASSERT( a7 == zero); |
| 176 |
> |
a7 = 2.0 * one; |
| 177 |
> |
CPPUNIT_ASSERT( a7 == two); |
| 178 |
|
|
| 179 |
|
//test div |
| 180 |
< |
Vec4 a9; |
| 181 |
< |
a9 = two; |
| 182 |
< |
a9.div(2.0); |
| 183 |
< |
CPPUNIT_ASSERT( a9 == one); |
| 184 |
< |
|
| 185 |
< |
Vec4 a10; |
| 187 |
< |
a10.div(two, 2.0); |
| 188 |
< |
CPPUNIT_ASSERT( a10 == one); |
| 189 |
< |
Vec4 a11; |
| 190 |
< |
a11.mul(zero, 2.0); |
| 191 |
< |
CPPUNIT_ASSERT( a11 == zero); |
| 192 |
< |
|
| 180 |
> |
Vec4 a8; |
| 181 |
> |
a8 = two; |
| 182 |
> |
a8 /= 2.0; |
| 183 |
> |
CPPUNIT_ASSERT( a8 == one); |
| 184 |
> |
a8 = two /2.0; |
| 185 |
> |
CPPUNIT_ASSERT( a8 == one); |
| 186 |
|
} |
| 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); |
| 193 |
|
|
| 194 |
+ |
//test () operator |
| 195 |
|
CPPUNIT_ASSERT(v3(0) != 1.0); |
| 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)); |
| 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); |
| 209 |
+ |
|
| 210 |
+ |
//test normalize() |
| 211 |
+ |
Vec4 a1 = one; |
| 212 |
+ |
Vec4 a2 = two; |
| 213 |
+ |
|
| 214 |
+ |
a1.normalize(); |
| 215 |
+ |
a2.normalize(); |
| 216 |
+ |
CPPUNIT_ASSERT(a1 == a2); |
| 217 |
+ |
|
| 218 |
+ |
//test isNormalized(); |
| 219 |
+ |
CPPUNIT_ASSERT(a1.isNormalized()); |
| 220 |
+ |
CPPUNIT_ASSERT(!one.isNormalized()); |
| 221 |
+ |
|
| 222 |
+ |
|
| 223 |
+ |
} |
| 224 |
|
void VectorTestCase::testOtherTemplateFunctions(){ |
| 225 |
+ |
//test dot |
| 226 |
+ |
CPPUNIT_ASSERT(dot(one, two) == 8.0); |
| 227 |
+ |
CPPUNIT_ASSERT(dot(v1, v3) == 20.0); |
| 228 |
|
|
| 229 |
+ |
//test distance |
| 230 |
+ |
CPPUNIT_ASSERT(distance(one, two) == 2.0); |
| 231 |
+ |
CPPUNIT_ASSERT(distance(v1, v2) == sqrt(56.0)); |
| 232 |
+ |
|
| 233 |
+ |
//test distanceSquare |
| 234 |
+ |
CPPUNIT_ASSERT(distanceSquare(one, two) == 4.0); |
| 235 |
+ |
CPPUNIT_ASSERT(distanceSquare(v1, v2) == 56); |
| 236 |
+ |
|
| 237 |
|
} |