]>
Commit | Line | Data |
---|---|---|
4e0938ef | 1 | /* |
f70aedc4 | 2 | * Copyright (C) 1996-2021 The Squid Software Foundation and contributors |
4e0938ef AJ |
3 | * |
4 | * Squid software is distributed under GPLv2+ license and includes | |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
7 | */ | |
8 | ||
7f861c77 AJ |
9 | #ifndef SQUID_INCLUDE_UNITTESTMAIN_H |
10 | #define SQUID_INCLUDE_UNITTESTMAIN_H | |
11 | ||
03714d23 FC |
12 | #if ENABLE_DEBUG_SECTION |
13 | #include "Debug.h" | |
14 | #endif /* ENABLE_DEBUG_SECTION */ | |
15 | ||
f5691f9c | 16 | #include <cppunit/BriefTestProgressListener.h> |
17 | #include <cppunit/TextTestProgressListener.h> | |
18 | #include <cppunit/CompilerOutputter.h> | |
19 | #include <cppunit/extensions/TestFactoryRegistry.h> | |
20 | #include <cppunit/TestResult.h> | |
21 | #include <cppunit/TestResultCollector.h> | |
22 | #include <cppunit/TestRunner.h> | |
23 | ||
f5691f9c | 24 | int |
72ed5979 | 25 | main(int, char *[]) |
f5691f9c | 26 | { |
03714d23 FC |
27 | #if ENABLE_DEBUG_SECTION |
28 | Debug::Levels[ENABLE_DEBUG_SECTION] = 99; | |
29 | #endif | |
30 | ||
f5691f9c | 31 | // Create the event manager and test controller |
32 | CPPUNIT_NS::TestResult controller; | |
33 | ||
34 | // Add a listener that colllects test result | |
35 | CPPUNIT_NS::TestResultCollector result; | |
36 | controller.addListener( &result ); | |
37 | ||
38 | // Add a listener that print dots as test run. | |
39 | // use BriefTestProgressListener to get names of each test | |
40 | // even when they pass. | |
7f861c77 | 41 | // CPPUNIT_NS::BriefTestProgressListener progress; |
f5691f9c | 42 | CPPUNIT_NS::TextTestProgressListener progress; |
43 | controller.addListener( &progress ); | |
44 | ||
45 | // Add the top suite to the test runner | |
46 | CPPUNIT_NS::TestRunner runner; | |
47 | runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() ); | |
48 | runner.run( controller ); | |
49 | ||
50 | // Print test in a compiler compatible format. | |
51 | CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr ); | |
52 | outputter.write(); | |
53 | ||
54 | return result.wasSuccessful() ? 0 : 1; | |
55 | } | |
f53969cc | 56 | |
7f861c77 | 57 | #endif /* SQUID_INCLUDE_UNITTESTMAIN_H */ |
8dd8e707 | 58 |