Update NEWS and UPGRADING for 2.7.1
[networkupstools/kirr.git] / tests / cpputest.cpp
blob448dd5b056e8e6d3a4d2af27b4849b62fb4e581f
1 /* cpputest - basic runner for unit tests
3 Copyright (C)
4 2012 Emilien Kia <emilienkia-guest@alioth.debian.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <cppunit/CompilerOutputter.h>
22 #include <cppunit/extensions/TestFactoryRegistry.h>
23 #include <cppunit/ui/text/TestRunner.h>
26 int main(int argc, char* argv[])
28 /* Get the top level suite from the registry */
29 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
31 /* Adds the test to the list of test to run */
32 CppUnit::TextUi::TestRunner runner;
33 runner.addTest( suite );
35 /* Change the default outputter to a compiler error format outputter */
36 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
37 std::cerr ) );
38 /* Run the tests. */
39 bool wasSucessful = runner.run();
41 /* Return error code 1 if the one of test failed. */
42 return wasSucessful ? 0 : 1;