|
Boost : |
From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2002-11-20 09:37:15
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk