peteb / tankage

Multiplayer 2D tank game; drive around in a mutable world together with friends
10 stars 2 forks source link

Unit test for vec2 #20

Closed kskels closed 13 years ago

kskels commented 13 years ago

Added some unit test for vec2. I know it's kind a simple but still I had some questions there. I you have time please take a look in ~src/math/unittest/math_unittest.cpp. There are couple of questions.

peteb commented 13 years ago

I think we should probably split the unit test into two unit tests, one for vectors and one for matrices. Or maybe this way is good. The rounding stuff, if GTest doesn't have built-in support for comparing floats, then we should just check if the difference between the two values is lower than a certain threshold. An epsilon value. http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm

kskels commented 13 years ago

And of course you are right, GTest has inbuilt support for floats!

EXPECT_FLOAT_EQ(expected, actual); // the two float values are almost equal
By "almost equal", we mean the two values are within 4 ULP's from each other.