-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCase.cxx
More file actions
105 lines (91 loc) · 2.48 KB
/
TestCase.cxx
File metadata and controls
105 lines (91 loc) · 2.48 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "TestCase.h"
#include <iostream>
//-------------------------------------------------------------------
// Constructor
TestCase::TestCase(string name) : m_name(name)
{
// set our default reportor as stdout (we have this as a member variable
// and are just pointing our pointer to this member variable)
m_reporter = &m_defaultReporter;
}
//-------------------------------------------------------------------
// Destructor - clean-up memory from this test
TestCase::~TestCase(void)
{
}
//-------------------------------------------------------------------
// Register a reporter which is used in logging messages and reporting
// on the test execution
void TestCase::registerTestReporter(TestReporter* reporter)
{
// set our report to the one provided
m_reporter = reporter;
}
//-------------------------------------------------------------------
// Return the name of the test being executed
string TestCase::getTestName()
{
return m_name;
}
/*
bool TestCase::run()
{
bool passed = true;
long passedTests = 0;
long failedTests = 0;
for (int i = 0; i < m_testCount; i++)
{
try {
*this << "Running test: " << m_testNames[i] << "\n";
*this << "==============";
for (size_t l = 0; l < m_testNames[i].size(); l++)
{
*this << "=";
}
*this << "\n";
this->setUp();
(m_tests[i])(this);
this->tearDown();
passedTests++;
*this << "Test PASSED" << "\n\n";
}
catch (TestFail failure)
{
failedTests++;
passed = false;
*this << "[" << failure.m_msg << "]" << "\n";
*this << "Test FAILED" << "\n\n";
}
catch (...)
{
failedTests++;
passed = false;
*this << "[Unexpected exception caused test to fail]" << "\n";
*this << "Test FAILED" << "\n\n";
}
}
*this << passedTests << " tests passed" << "\n";
*this << failedTests << " tests failed" << "\n";
return passed;
}
*/
void TestCase::setUp()
{
}
void TestCase::tearDown()
{
}
void TestCase::assertTrue(bool val) throw (TestFail)
{
if (!val)
{
throw TestFail();
}
}
void TestCase::assertTrue(string msg, bool val) throw (TestFail)
{
if (!val)
{
throw TestFail(msg);
}
}