Menu

#6 Example Code on Home page

open
nobody
None
5
2010-07-30
2010-07-30
No

Hi!

I was trying to compile the example code on the web page http://unitpp.sourceforge.net/ but I wasn't able to compile it directly with GCC version 4.5.0. I modified the example a little and this did compile and work:

#include <unit++.h>
using namespace unitpp;

namespace {
class Test : public suite {
void test1()
{
assert_true("Compiler sanity", true);
}
public:
Test()
: suite("The Demo Suite")
{
// make the test1 method a test in this suite
add("test1", testcase(this, "Demo test", &Test::test1));
// add this suite to the main suite
suite::main().add("demo", this);
}
};
Test* theTest = new Test();
}

Finally, I ran the command:
g++ -o test test.cpp -lunit++

Discussion


Log in to post a comment.