source: molecuilder/src/unittests/infounittest.cpp@ 14c0f0

Last change on this file since 14c0f0 was edf611, checked in by Frederik Heber <heber@…>, 16 years ago

New Info class that contains a global verbosity level, increased per function call and decreased per exit.

  • the idea is to have the "begin of .." and "end of .." messages in an object that automatically holds the current recursion level and hence may change verbosity accordingly for Logger
  • verbose::DoOutput() checks relative to Info::verbosity now.
  • InfoUnitTest was done and works well.

Signed-off-by: Frederik Heber <heber@…>

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 * InfoUnitTest.cpp
3 *
4 * Created on: Nov 25, 2009
5 * Author: heber
6 */
7
8using namespace std;
9
10#include <cppunit/CompilerOutputter.h>
11#include <cppunit/extensions/TestFactoryRegistry.h>
12#include <cppunit/ui/text/TestRunner.h>
13
14#include <iostream>
15#include <stdio.h>
16
17#include "info.hpp"
18#include "infounittest.hpp"
19
20/********************************************** Test classes **************************************/
21
22// Registers the fixture into the 'registry'
23CPPUNIT_TEST_SUITE_REGISTRATION( InfoTest );
24
25
26void InfoTest::setUp()
27{
28};
29
30
31void InfoTest::tearDown()
32{
33};
34
35/** UnitTest for FunctionTest().
36 */
37void InfoTest::FunctionTest()
38{
39 const char *msg = __func__;
40 class Info test(msg);
41
42 CPPUNIT_ASSERT_EQUAL( msg , test.FunctionName );
43 CPPUNIT_ASSERT_EQUAL( 1, test.verbosity );
44};
45
46
47/********************************************** Main routine **************************************/
48
49int main(int argc, char **argv)
50{
51 // Get the top level suite from the registry
52 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
53
54 // Adds the test to the list of test to run
55 CppUnit::TextUi::TestRunner runner;
56 runner.addTest( suite );
57
58 // Change the default outputter to a compiler error format outputter
59 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
60 std::cerr ) );
61 // Run the tests.
62 bool wasSucessful = runner.run();
63
64 // Return error code 1 if the one of test failed.
65 return wasSucessful ? 0 : 1;
66};
Note: See TracBrowser for help on using the repository browser.