blob: 4371c50306650e3f2feea8e69e2af7385c5eaf9e (
plain)
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
106
107
108
109
110
111
112
113
114
115
116
117
|
#include <cppunit/TestFailure.h>
#include <cppunit/TestResultCollector.h>
CPPUNIT_NS_BEGIN
TestResultCollector::TestResultCollector( SynchronizationObject *syncObject )
: TestSuccessListener( syncObject )
{
reset();
}
TestResultCollector::~TestResultCollector()
{
freeFailures();
}
void
TestResultCollector::freeFailures()
{
TestFailures::iterator itFailure = m_failures.begin();
while ( itFailure != m_failures.end() )
delete *itFailure++;
m_failures.clear();
}
void
TestResultCollector::reset()
{
TestSuccessListener::reset();
ExclusiveZone zone( m_syncObject );
freeFailures();
m_testErrors = 0;
m_tests.clear();
}
void
TestResultCollector::startTest( Test *test )
{
ExclusiveZone zone (m_syncObject);
m_tests.push_back( test );
}
void
TestResultCollector::addFailure( const TestFailure &failure )
{
TestSuccessListener::addFailure( failure );
ExclusiveZone zone( m_syncObject );
if ( failure.isError() )
++m_testErrors;
m_failures.push_back( failure.clone() );
}
/// Gets the number of run tests.
int
TestResultCollector::runTests() const
{
ExclusiveZone zone( m_syncObject );
return m_tests.size();
}
/// Gets the number of detected errors (uncaught exception).
int
TestResultCollector::testErrors() const
{
ExclusiveZone zone( m_syncObject );
return m_testErrors;
}
/// Gets the number of detected failures (failed assertion).
int
TestResultCollector::testFailures() const
{
ExclusiveZone zone( m_syncObject );
return m_failures.size() - m_testErrors;
}
/// Gets the total number of detected failures.
int
TestResultCollector::testFailuresTotal() const
{
ExclusiveZone zone( m_syncObject );
return m_failures.size();
}
/// Returns a the list failures (random access collection).
const TestResultCollector::TestFailures &
TestResultCollector::failures() const
{
ExclusiveZone zone( m_syncObject );
return m_failures;
}
const TestResultCollector::Tests &
TestResultCollector::tests() const
{
ExclusiveZone zone( m_syncObject );
return m_tests;
}
CPPUNIT_NS_END
|