Altered [CHECK|EXPECT]_DOUBLES_EQUAL such that nan values automatically cause the test to fail. The previous approach would always return pass if one of the compared values is nan, resulting in tests passing when they shouldn't. If you have a test where you want to check that the value is nan, use EXPECT(isnan(x));, where x is the value you want to test.

release/4.3a0
Alex Cunningham 2013-08-02 15:21:36 +00:00
parent 95ffb0c4ea
commit 3545b114ab
1 changed files with 2 additions and 2 deletions

View File

@ -130,7 +130,7 @@ boost::lexical_cast<std::string>(actualTemp))); return; } }
#define DOUBLES_EQUAL(expected,actual,threshold)\
{ double actualTemp = actual; \
double expectedTemp = expected; \
if (fabs ((expectedTemp)-(actualTemp)) > threshold) \
if (isnan(actualTemp) || isnan(expectedTemp) || fabs ((expectedTemp)-(actualTemp)) > threshold) \
{ result_.addFailure (Failure (name_, __FILE__, __LINE__, \
boost::lexical_cast<std::string>((double)expectedTemp), boost::lexical_cast<std::string>((double)actualTemp))); return; } }
@ -150,7 +150,7 @@ boost::lexical_cast<std::string>(actualTemp))); } }
#define EXPECT_DOUBLES_EQUAL(expected,actual,threshold)\
{ double actualTemp = actual; \
double expectedTemp = expected; \
if (fabs ((expectedTemp)-(actualTemp)) > threshold) \
if (isnan(actualTemp) || isnan(expectedTemp) || fabs ((expectedTemp)-(actualTemp)) > threshold) \
{ result_.addFailure (Failure (name_, __FILE__, __LINE__, \
boost::lexical_cast<std::string>((double)expectedTemp), boost::lexical_cast<std::string>((double)actualTemp))); } }