I'm trying to start writing tests for all of my functions as per Test Driven Development. My question is, say I construct a test for "rotate vector". It would be something like this:
int TestRotateVector(const Vector &V)
{
Vector Original(1.0, 2.0);
Vector Rotated = Original.Rotate(10); //rotate 10 degrees
if(Rotated == Vector(2.34, 5.67)) //...whatever the correct answer should be
return 0; //pass
else
return -1; //fail
}
So my question is, do I have to use epsilon tests to test this kind of equality - i.e. if( fabs(Rotated.x - 2.34) < epsilon && fabs(Rotated.y - 5.67) < epsilon)
? Or is there a better way to write test functions?
Thanks,
Dave