Closed
Description
Copied from https://sourceforge.net/tracker/?func=detail&aid=1844387&group_id=158151&atid=806684
If the "actual" value passed into CHECK_EQUAL is NULL, std::strcmp() will throw an exception in CheckStringsEqual(). Here's is my simple workaround:
void CheckStringsEqual(TestResults& results, char const* expected, char const* actual, TestDetails const& details)
{
// WAS: if (std::strcmp(expected, actual))
if (actual == NULL || std::strcmp(expected, actual))
{
UnitTest::MemoryOutStream stream;
// WAS: stream << "Expected " << expected << " but was " << actual;
stream << "Expected " << expected << " but was " << (actual ? actual : "(null)");
results.OnTestFailure(details, stream.GetText());
}
}
There are a few possible patches in the comments of the original bug to consider for incorporation. It should be noted, though, that the test does correctly fail on the CHECK_EQUAL invocation, so I marked this as an enhancement, as opposed to a bug.