Hi,

the (really useful!) boost test library provides the test tool macro BOOST_CHECK_EQUAL() which checks two values for equality. I just learned the hard way that the following does not do what one would expect.

char const *p = 0;
BOOST_CHECK_EQUAL(p, p);

On my system, this results in a test program crash. The reason is, for this parameter type strcmp() is called which (of course) doesn't like NULL pointers as it's arguments.

This isn't documented anywhere in the test library documentation (neither the special treatment of char * nor the requirement that those must not be NULL) and I think it needs to be fixed. There are several possible ways.

1. Just document it. Not so good, IMHO.

2. Document the special case and add a check for NULL pointers before calling strcmp().

3. Remove the special case alltogether. After all, I might want to check that the pointers are equal and not the string they point to. This might be the best solution, but breaks backward compatibility.

Markus





_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to