1 | /*
|
---|
2 | * InfoUnitTest.cpp
|
---|
3 | *
|
---|
4 | * Created on: Nov 25, 2009
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 | using 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'
|
---|
23 | CPPUNIT_TEST_SUITE_REGISTRATION( InfoTest );
|
---|
24 |
|
---|
25 |
|
---|
26 | void InfoTest::setUp()
|
---|
27 | {
|
---|
28 | };
|
---|
29 |
|
---|
30 |
|
---|
31 | void InfoTest::tearDown()
|
---|
32 | {
|
---|
33 | };
|
---|
34 |
|
---|
35 | /** UnitTest for FunctionTest().
|
---|
36 | */
|
---|
37 | void 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 |
|
---|
49 | int 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 | };
|
---|