blob: d262886156219c07b46dc816405377b00fbdc329 (
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
|
/*
* iTchRunnerReporter.h
* iTchRunner
*
* Created by Phil on 07/02/2011.
* Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
*
*/
#ifndef TWOBLUECUBES_ITCHRUNNERREPORTER_H_INCLUDED
#define TWOBLUECUBES_ITCHRUNNERREPORTER_H_INCLUDED
#include "catch.hpp"
@protocol iTchRunnerDelegate
-(void) testWasRun: (const Catch::AssertionResult*) result;
@end
namespace Catch
{
class iTchRunnerReporter : public SharedImpl<IReporter>
{
public:
///////////////////////////////////////////////////////////////////////////
iTchRunnerReporter
(
id<iTchRunnerDelegate> delegate
)
: m_delegate( delegate )
{
}
///////////////////////////////////////////////////////////////////////////
virtual bool shouldRedirectStdout
()
const
{
return true;
}
///////////////////////////////////////////////////////////////////////////
static std::string getDescription
()
{
return "Captures results for iOS runner";
}
///////////////////////////////////////////////////////////////////////////
size_t getSucceeded
()
const
{
return m_totals.assertions.passed;
}
///////////////////////////////////////////////////////////////////////////
size_t getFailed
()
const
{
return m_totals.assertions.failed;
}
///////////////////////////////////////////////////////////////////////////
void reset()
{
m_totals = Totals();
}
private: // IReporter
///////////////////////////////////////////////////////////////////////////
virtual void StartTesting
()
{}
///////////////////////////////////////////////////////////////////////////
virtual void EndTesting
(
const Totals& totals
)
{
m_totals = totals;
}
///////////////////////////////////////////////////////////////////////////
virtual void Result
(
const AssertionResult& result
)
{
[m_delegate testWasRun: &result];
}
///////////////////////////////////////////////////////////////////////////
// Deliberately unimplemented:
virtual void StartGroup( const std::string& ){}
virtual void EndGroup( const std::string&, const Totals& ){}
virtual void StartTestCase( const TestCaseInfo& ){}
virtual void StartSection( const std::string& sectionName, const std::string& description ) {}
virtual void EndSection( const std::string&, const Counts& ){}
virtual void EndTestCase( const TestCaseInfo&, const Totals&, const std::string&, const std::string& ){}
virtual void Aborted() {}
virtual void NoAssertionsInSection( std::string const& sectionName ) {}
virtual void NoAssertionsInTestCase( std::string const& testName ) {}
private:
Totals m_totals;
id<iTchRunnerDelegate> m_delegate;
};
}
#endif // TWOBLUECUBES_ITCHRUNNERREPORTER_H_INCLUDED
|