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.
parent
95ffb0c4ea
commit
3545b114ab
|
@ -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))); } }
|
||||
|
||||
|
|
Loading…
Reference in New Issue