-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestmain.cpp
38 lines (29 loc) · 1.13 KB
/
testmain.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// File 'testmain.cpp', 11.04.2013 phoerler
#include <cppunit/TextTestProgressListener.h>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
int main( int argc, char* argv[] )
{
// Create the event manager and test controller:
CppUnit::TestResult controller;
// Add a listener that colllects test result:
CppUnit::TestResultCollector result;
controller.addListener( &result );
// Add a listener that print dots as test run:
// CppUnit::TextTestProgressListener progress;
CppUnit::BriefTestProgressListener progress;
controller.addListener( &progress );
// Add the top suite in the registry to the test runner
CppUnit::TestRunner runner;
runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() );
// Run the tests:
runner.run( controller );
// Print test in a compiler compatible format.
CppUnit::CompilerOutputter outputter( &result, std::cout );
outputter.write();
return result.wasSuccessful() ? 0 : 1;
}