Closed
Description
From http://code.google.com/p/unittestpp/issues/detail?id=21
What steps will reproduce the problem?
- Use this test:
TEST(checkEqualTest) {
CHECK_EQUAL(DBL_MAX, 0.0);
} - Run it.
- Notice how it crashes. If it doesn't crash on your system, run it in valgrind.
What is the expected output? What do you see instead?
It shouldn't crash.
What version of the product are you using? On what operating system?
v1.4
Please provide any additional information below.
The problem is happening in MemoryOutStream.cpp in FormatToStream :
template<typename ValueType>
void FormatToStream(MemoryOutStream& stream, char const* format, ValueType const& value)
{
using namespace std;
char txt[32];
sprintf(txt, format, value);
stream << txt;
}
When formatting most numbers the size of txt is sufficient. However, for things like DBL_MAX which has more than 300 digits, this will fall down. The quick fix is to use a large size for txt. The good fix is to use snprintf.