Line data Source code
1 : #include <cppunit/BriefTestProgressListener.h>
2 : #include <cppunit/CompilerOutputter.h>
3 : #include <cppunit/extensions/TestFactoryRegistry.h>
4 : #include <cppunit/TestResult.h>
5 : #include <cppunit/TestResultCollector.h>
6 : #include <cppunit/TestRunner.h>
7 :
8 1 : int main() {
9 : // Create the event manager and test controller
10 1 : CPPUNIT_NS::TestResult controller;
11 :
12 : // Add a listener that colllects test result
13 2 : CPPUNIT_NS::TestResultCollector result;
14 1 : controller.addListener(&result);
15 :
16 : // Add a listener that print dots as test run.
17 2 : CPPUNIT_NS::BriefTestProgressListener progress;
18 1 : controller.addListener(&progress);
19 :
20 : // Add the top suite to the test runner
21 2 : CPPUNIT_NS::TestRunner runner;
22 1 : runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
23 1 : runner.run(controller);
24 :
25 : // Print test in a compiler compatible format.
26 2 : CPPUNIT_NS::CompilerOutputter outputter(&result, CPPUNIT_NS::stdCOut());
27 1 : outputter.write();
28 :
29 2 : return result.wasSuccessful() ? 0 : 1;
30 3 : }
|