main.cpp (722B)
1 #include <cppunit/CompilerOutputter.h> 2 #include <cppunit/extensions/TestFactoryRegistry.h> 3 #include <cppunit/ui/text/TextTestRunner.h> 4 5 int main(int argc, char* argv[]) 6 { 7 // Get the top level suite from the registry 8 CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest(); 9 10 // Adds the test to the list of test to run 11 CPPUNIT_NS::TextTestRunner runner; 12 runner.addTest( suite ); 13 14 // Change the default outputter to a compiler error format outputter 15 runner.setOutputter( new CPPUNIT_NS::CompilerOutputter( &runner.result(), std::cout ) ); 16 // Run the test. 17 bool wasSucessful = runner.run(); 18 19 // Return error code 1 if the one of test failed. 20 return wasSucessful ? 0 : 1; 21 } 22