source: src/unittests/ChronosUnitTest.cpp@ 93abe8

Last change on this file since 93abe8 was 93abe8, checked in by Frederik Heber <heber@…>, 15 years ago

Added static and private object counter Info::NumberInfos.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * ChronosUnitTest.cpp
10 */
11
12
13// include config.h
14#ifdef HAVE_CONFIG_H
15#include <config.h>
16#endif
17
18using namespace std;
19
20#include <cppunit/CompilerOutputter.h>
21#include <cppunit/extensions/TestFactoryRegistry.h>
22#include <cppunit/ui/text/TestRunner.h>
23
24#include "Chronos.hpp"
25#include "Info.hpp"
26
27#include "ChronosUnitTest.hpp"
28
29#ifdef HAVE_TESTRUNNER
30#include "UnitTestMain.hpp"
31#endif /*HAVE_TESTRUNNER*/
32
33/********************************************** Test classes **************************************/
34
35// Registers the fixture into the 'registry'
36CPPUNIT_TEST_SUITE_REGISTRATION( ChronosTest );
37
38
39void dummy()
40{
41 Info FunctionInfo(__func__);
42}
43
44void dummy_two()
45{
46 Info FunctionInfo(__func__);
47}
48
49
50void ChronosTest::setUp()
51{
52}
53
54void ChronosTest::tearDown()
55{
56 Chronos::purgeInstance();
57}
58
59/**
60 * UnitTest for Chronos()
61 */
62void ChronosTest::InstanceTest()
63{
64 // check that we get a Non-NULL pointer
65 CPPUNIT_ASSERT(Chronos::getPointer());
66}
67
68/**
69 * UnitTest for Chronos()
70 */
71void ChronosTest::InfoTest()
72{
73 Info FunctionInfo(__func__);
74 CPPUNIT_ASSERT_EQUAL( (size_t) 1, Info::NumberInfos );
75}
76
77/**
78 * UnitTest for Chronos()
79 */
80void ChronosTest::dummyTest()
81{
82 // first dummy
83 dummy();
84 CPPUNIT_ASSERT( Chronos::getInstance().IsTimeRunning.find(std::string("dummy"))
85 != Chronos::getInstance().IsTimeRunning.end() );
86 CPPUNIT_ASSERT_EQUAL( (size_t) 1, Chronos::getInstance().SumUpTotalFunctions() );
87 dummy();
88 // second call goes to same entry
89 CPPUNIT_ASSERT_EQUAL( (size_t) 1, Chronos::getInstance().SumUpTotalFunctions() );
90
91 // second dummy
92 dummy_two();
93 CPPUNIT_ASSERT( Chronos::getInstance().IsTimeRunning.find(std::string("dummy_two"))
94 != Chronos::getInstance().IsTimeRunning.end() );
95 CPPUNIT_ASSERT_EQUAL( (size_t) 2, Chronos::getInstance().SumUpTotalFunctions() );
96}
Note: See TracBrowser for help on using the repository browser.