The unitpp name space holds all the stuff needed to use the unit++ testing framework.
The unitpp name space holds all the stuff needed to use the unit++ testing framework.The normal way to make a test is like this:
#include<unit++.h> using namespace unitpp; // use anonymous namespace so all test classes can be named Test namespace { class Test : public suite { void test1() { // do test stuff assert_true("message", exp1); // exp1 should be true assert_eq("another msg", 123456, exp2); // exp2 should be 123456 // ... } void test2() { // do something that provokes exception out_of_range } public: Test() : suite("appropriate name for test suite") { // any setup you need add("id1", testcase(this, "Test 1", &Test::test1)); // make a testcase from the method testcase tc(this, "Test 2", &Test::test2); // add a testcase that expects the exception add("id2", exception_case<out_of_range>(tc)); // add the suite to the global test suite suite::main().add("id", this); } } * theTest = new Test(); // by new, since testcase claims ownership }In order to make an executable test, simply link the above code against libunit++, something like
g++ -o test++ mytest.cc -L <location of libunit++> -lunit++
This will generate a test called test++ and the standard behaviour for a test. Note that most shells have test defined as a shell builtin which makes it a moderately bad name for a program, since it is rather hard to get executed, hence test++.
Alphabetic index HTML hierarchy of classes or Java