~iheino+ub/+junk/nut-upsconf-docfix

« back to all changes in this revision

Viewing changes to tests/cpputest.cpp

  • Committer: Tuomas Heino
  • Author(s): Laurent Bigonville
  • Date: 2014-04-22 20:46:12 UTC
  • Revision ID: iheino+ub@cc.hut.fi-20140422204612-1x2gh3nkezfsdao4
Tags: upstream-2.7.2
ImportĀ upstreamĀ versionĀ 2.7.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* cpputest - basic runner for unit tests
 
2
 
 
3
   Copyright (C)
 
4
        2012    Emilien Kia <emilienkia-guest@alioth.debian.org>
 
5
 
 
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.
 
10
 
 
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.
 
15
 
 
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
 
19
*/
 
20
 
 
21
#include <cppunit/CompilerOutputter.h>
 
22
#include <cppunit/extensions/TestFactoryRegistry.h>
 
23
#include <cppunit/ui/text/TestRunner.h>
 
24
 
 
25
 
 
26
int main(int argc, char* argv[])
 
27
{
 
28
  /* Get the top level suite from the registry */
 
29
  CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
 
30
 
 
31
  /* Adds the test to the list of test to run */
 
32
  CppUnit::TextUi::TestRunner runner;
 
33
  runner.addTest( suite );
 
34
 
 
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();
 
40
 
 
41
  /* Return error code 1 if the one of test failed. */
 
42
  return wasSucessful ? 0 : 1;
 
43
}
 
44