This repository has been archived by the owner on Oct 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ClockTest.cpp
83 lines (67 loc) · 2.15 KB
/
ClockTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* ClockTest.cpp
* MonkeyWorksCore
*
* Created by bkennedy on 10/30/08.
* Copyright 2008 mit. All rights reserved.
*
*/
#include "ClockTest.h"
#include "Clock.h"
using namespace mw;
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ClockTestFixture, "Unit Test" );
void ClockTestFixture::setUp() {
shared_ptr <Clock> shared_clock = Clock::instance(false);
CPPUNIT_ASSERT(shared_clock == NULL);
}
void ClockTestFixture::tearDown() {
shared_ptr <Clock> shared_clock = Clock::instance(false);
CPPUNIT_ASSERT(shared_clock == NULL);
}
void ClockTestFixture::testClock(){
shared_ptr <Clock> shared_clock = Clock::instance(false);
CPPUNIT_ASSERT(shared_clock == NULL);
for(int clock_creation = 0; clock_creation < 5; ++clock_creation) {
shared_clock = Clock::instance(false);
CPPUNIT_ASSERT(shared_clock == NULL);
bool threw_exception = false;
try {
shared_clock = Clock::instance(true);
} catch (SimpleException &e) {
threw_exception = true;
}
CPPUNIT_ASSERT(threw_exception);
threw_exception = false;
try {
shared_clock = Clock::instance();
} catch (SimpleException &e) {
threw_exception = true;
}
CPPUNIT_ASSERT(threw_exception);
shared_clock = Clock::instance(false);
CPPUNIT_ASSERT(shared_clock == NULL);
shared_ptr <Clock> new_clock = shared_ptr<Clock>(new Clock(0));
Clock::registerInstance(new_clock);
shared_clock = Clock::instance(false);
CPPUNIT_ASSERT(shared_clock != NULL);
Clock::destroy();
shared_clock = Clock::instance(false);
CPPUNIT_ASSERT(shared_clock == NULL);
new_clock = shared_ptr<Clock>(new Clock(0));
Clock::registerInstance(new_clock);
shared_clock = Clock::instance(true);
CPPUNIT_ASSERT(shared_clock != NULL);
Clock::destroy();
shared_clock = Clock::instance(false);
CPPUNIT_ASSERT(shared_clock == NULL);
new_clock = shared_ptr<Clock>(new Clock(0));
Clock::registerInstance(new_clock);
shared_clock = Clock::instance();
CPPUNIT_ASSERT(shared_clock != NULL);
Clock::destroy();
shared_clock = Clock::instance(false);
CPPUNIT_ASSERT(shared_clock == NULL);
}
shared_clock = Clock::instance(false);
CPPUNIT_ASSERT(shared_clock == NULL);
}