cxxtest

Macro define about cxxtest


I'm using cxxtest4.0.3 under vc6 to do a test. At first, the compiler report strcmp is not a member of std. After I added the CXXTEST_OLD_STD macro to project settings, the compiler report missing type info of string at the line "CXXTEST_STD(string) _s;".

How should I set the macro define? thanks in advanced.

Here is the sample code:

#include <cxxtest/TestSuite.h>
class CSimpleTest : public CxxTest::TestSuite  
{  
public:  
    void testCxx(void){TS_ASSERT(10 == 0); }  
};

Here is the error message:
error C2039: 'strcmp' : is not a member of 'std'
The line in cxxtest\testmain.h report the error message:

if ((CXXTEST_STD(strcmp)(argv[i],"-h")==0) || (CXXTEST_STD(strcmp)(argv[i],"--help")==0)) { 

Solution

  • I don't have access to MS Visual Studio 6, but isn't that a little on the archaic side? It was released in June 1998 according to Wikipedia, and the first C++ standard was released in November 1998. So, I would suspect that your C++ compiler is simply too old to be supported by cxxtest.

    You could look at the option to cxxgentest:

    --no-std              Do not use standard library (even if found in tests).
    

    You can check other options with cxxgentest --help.


    It isn't much help to tell you that cxxtest 4.0.3 worked find on MacOS X 10.7.3 with G++ i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00), but it did — or, at least, your sample program compiled to object file without warnings under:

    bin/cxxtestgen -o cxt.cpp test.simple.cpp
    g++ -I. -c -Wall -Wextra -o cxt.o cxt.cpp