Checking for equality of C strings

Dave Glowacki <[email protected]> Thu, 13 Feb 2003 17:12:47 -0600
Newsgroups gmane.comp.lib.cppunit.devel
Message-ID <[email protected]>
If I try to do something like this:

    const char *sample = "Sample String";

    char copy[16];
    strcpy(copy, sample);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Identical strings are not equal",
                                 (const char *)copy, sample);

I end up getting an assertion like this:

    charcompare.cpp:15:Assertion
    Test name: CharCompare::testCompare
    equality assertion failed
    - Expected: Sample String
    - Actual  : Sample String
    - Identical strings are not equal

Is there a variant of CPPUNIT_ASSERT_EQUAL macro which can compare
C strings?  Extra points if it can compare a 'char[]' and a 'char *'!


-------------------------------------------------------
This SF.NET email is sponsored by: FREE  SSL Guide from Thawte
are you planning your Web Server Security? Click here to get a FREE
Thawte SSL guide and find the answers to all your  SSL security issues.
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en