#147 assertion_traits<T>::equal fails for arguments of type char*


This fails in 1.11.0 as well.

I don't know if this is a bug or a case of "just don't use it
that way".

I found this while writing some unit tests for a corba
apllication. Corba has its own type to represent string
data. When verifying the corba string return value from a
server call, I converted the corba string and the expected
std::string to const char* and used
CPPUNIT_ASSERT_EQUAL. The strings matched but
the assertion failed. I ending up adding the following
code to the .cpp file of my test class to fix the problem.

template <>
struct assertion_traits<const char*>
static bool equal(const char* x, const char* y)
return !strcmp(x, y);

static std::string toString(const char *x)
return x;

A Test class for this is attached.

my email is cflowe@weather.com


  • Nobody/Anonymous

    Test class and fix for the issue

  • Baptiste Lepilleur

    • assigned_to: nobody --> blep
  • Baptiste Lepilleur

    Logged In: YES

    This is the expected behavior. There is no guaranty of what
    a const char * pointer represents (could be binary data).

    If this is an issue, a CPPUNIT_ASSERT_STRING_EQUAL could be
    introduced (just like in CppUnit 2).



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks