Testing/Source/catch.h

Tue, 06 Jul 2021 10:22:49 +0300

author
cemkalyoncu
date
Tue, 06 Jul 2021 10:22:49 +0300
branch
4.x-dev
changeset 1701
b168349a931d
parent 416
7c04a3e33dcc
permissions
-rw-r--r--

* Image/Bitmap rotate

416
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1 /*
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
2 * CATCH v1.0 build 32 (master branch)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
3 * Generated: 2014-03-17 18:37:08.497437
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
4 * ----------------------------------------------------------
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
5 * This file has been merged from multiple headers. Please don't edit it directly
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
6 * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
7 *
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
8 * Distributed under the Boost Software License, Version 1.0. (See accompanying
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
9 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
10 */
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
11 #ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
12 #define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
13
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
14 #define TWOBLUECUBES_CATCH_HPP_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
15
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
16 #ifdef __clang__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
17 #pragma clang diagnostic ignored "-Wglobal-constructors"
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
18 #pragma clang diagnostic ignored "-Wvariadic-macros"
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
19 #pragma clang diagnostic ignored "-Wc99-extensions"
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
20 #pragma clang diagnostic push
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
21 #pragma clang diagnostic ignored "-Wpadded"
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
22 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
23
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
24 #ifdef CATCH_CONFIG_MAIN
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
25 # define CATCH_CONFIG_RUNNER
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
26 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
27
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
28 #ifdef CATCH_CONFIG_RUNNER
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
29 # ifndef CLARA_CONFIG_MAIN
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
30 # define CLARA_CONFIG_MAIN_NOT_DEFINED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
31 # define CLARA_CONFIG_MAIN
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
32 # endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
33 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
34
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
35 // #included from: internal/catch_notimplemented_exception.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
36 #define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
37
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
38 // #included from: catch_common.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
39 #define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
40
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
41 #define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
42 #define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
43 #define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
44
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
45 #define INTERNAL_CATCH_STRINGIFY2( expr ) #expr
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
46 #define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
47
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
48 #include <sstream>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
49 #include <stdexcept>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
50 #include <algorithm>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
51
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
52 // #included from: catch_compiler_capabilities.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
53 #define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
54
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
55 // Much of the following code is based on Boost (1.53)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
56
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
57 #ifdef __clang__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
58
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
59 #if __has_feature(cxx_nullptr)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
60
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
61 #define CATCH_CONFIG_CPP11_NULLPTR
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
62
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
63 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
64
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
65 #endif // __clang__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
66
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
67 ////////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
68 // Borland
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
69 #ifdef __BORLANDC__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
70
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
71 #if (__BORLANDC__ > 0x582 )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
72 //#define CATCH_CONFIG_SFINAE // Not confirmed
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
73 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
74
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
75 #endif // __BORLANDC__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
76
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
77 ////////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
78 // EDG
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
79 #ifdef __EDG_VERSION__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
80
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
81 #if (__EDG_VERSION__ > 238 )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
82 //#define CATCH_CONFIG_SFINAE // Not confirmed
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
83 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
84
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
85 #endif // __EDG_VERSION__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
86
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
87 ////////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
88 // Digital Mars
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
89 #ifdef __DMC__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
90
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
91 #if (__DMC__ > 0x840 )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
92 //#define CATCH_CONFIG_SFINAE // Not confirmed
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
93 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
94
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
95 #endif // __DMC__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
96
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
97 ////////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
98 // GCC
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
99 #ifdef __GNUC__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
100
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
101 #if __GNUC__ < 3
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
102
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
103 #if (__GNUC_MINOR__ >= 96 )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
104 //#define CATCH_CONFIG_SFINAE
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
105 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
106
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
107 #elif __GNUC__ >= 3
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
108
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
109 // #define CATCH_CONFIG_SFINAE // Taking this out completely for now
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
110
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
111 #endif // __GNUC__ < 3
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
112
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
113 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
114
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
115 #define CATCH_CONFIG_CPP11_NULLPTR
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
116 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
117
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
118 #endif // __GNUC__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
119
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
120 ////////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
121 // Visual C++
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
122 #ifdef _MSC_VER
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
123
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
124 #if (_MSC_VER >= 1310 ) // (VC++ 7.0+)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
125 //#define CATCH_CONFIG_SFINAE // Not confirmed
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
126 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
127
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
128 #endif // _MSC_VER
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
129
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
130 // Use variadic macros if the compiler supports them
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
131 #if ( defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
132 ( defined __WAVE__ && __WAVE_HAS_VARIADICS ) || \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
133 ( defined __GNUC__ && __GNUC__ >= 3 ) || \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
134 ( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
135
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
136 #ifndef CATCH_CONFIG_NO_VARIADIC_MACROS
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
137 #define CATCH_CONFIG_VARIADIC_MACROS
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
138 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
139
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
140 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
141
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
142 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
143
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
144 class NonCopyable {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
145 NonCopyable( NonCopyable const& );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
146 void operator = ( NonCopyable const& );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
147 protected:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
148 NonCopyable() {}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
149 virtual ~NonCopyable();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
150 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
151
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
152 class SafeBool {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
153 public:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
154 typedef void (SafeBool::*type)() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
155
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
156 static type makeSafe( bool value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
157 return value ? &SafeBool::trueValue : 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
158 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
159 private:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
160 void trueValue() const {}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
161 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
162
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
163 template<typename ContainerT>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
164 inline void deleteAll( ContainerT& container ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
165 typename ContainerT::const_iterator it = container.begin();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
166 typename ContainerT::const_iterator itEnd = container.end();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
167 for(; it != itEnd; ++it )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
168 delete *it;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
169 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
170 template<typename AssociativeContainerT>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
171 inline void deleteAllValues( AssociativeContainerT& container ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
172 typename AssociativeContainerT::const_iterator it = container.begin();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
173 typename AssociativeContainerT::const_iterator itEnd = container.end();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
174 for(; it != itEnd; ++it )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
175 delete it->second;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
176 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
177
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
178 bool startsWith( std::string const& s, std::string const& prefix );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
179 bool endsWith( std::string const& s, std::string const& suffix );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
180 bool contains( std::string const& s, std::string const& infix );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
181 void toLowerInPlace( std::string& s );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
182 std::string toLower( std::string const& s );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
183 std::string trim( std::string const& str );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
184
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
185 struct pluralise {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
186 pluralise( std::size_t count, std::string const& label );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
187
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
188 friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
189
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
190 std::size_t m_count;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
191 std::string m_label;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
192 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
193
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
194 struct SourceLineInfo {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
195
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
196 SourceLineInfo();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
197 SourceLineInfo( char const* _file, std::size_t _line );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
198 SourceLineInfo( SourceLineInfo const& other );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
199 bool empty() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
200 bool operator == ( SourceLineInfo const& other ) const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
201
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
202 std::string file;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
203 std::size_t line;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
204 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
205
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
206 std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
207
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
208 // This is just here to avoid compiler warnings with macro constants and boolean literals
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
209 inline bool isTrue( bool value ){ return value; }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
210
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
211 void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
212
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
213 // Use this in variadic streaming macros to allow
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
214 // >> +StreamEndStop
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
215 // as well as
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
216 // >> stuff +StreamEndStop
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
217 struct StreamEndStop {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
218 std::string operator+() {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
219 return std::string();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
220 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
221 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
222 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
223 T const& operator + ( T const& value, StreamEndStop ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
224 return value;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
225 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
226 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
227
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
228 #define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
229 #define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
230
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
231 #include <ostream>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
232
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
233 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
234
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
235 class NotImplementedException : public std::exception
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
236 {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
237 public:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
238 NotImplementedException( SourceLineInfo const& lineInfo );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
239
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
240 virtual ~NotImplementedException() throw() {}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
241
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
242 virtual const char* what() const throw();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
243
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
244 private:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
245 std::string m_what;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
246 SourceLineInfo m_lineInfo;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
247 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
248
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
249 } // end namespace Catch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
250
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
251 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
252 #define CATCH_NOT_IMPLEMENTED throw Catch::NotImplementedException( CATCH_INTERNAL_LINEINFO )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
253
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
254 // #included from: internal/catch_context.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
255 #define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
256
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
257 // #included from: catch_interfaces_generators.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
258 #define TWOBLUECUBES_CATCH_INTERFACES_GENERATORS_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
259
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
260 #include <string>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
261
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
262 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
263
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
264 struct IGeneratorInfo {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
265 virtual ~IGeneratorInfo();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
266 virtual bool moveNext() = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
267 virtual std::size_t getCurrentIndex() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
268 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
269
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
270 struct IGeneratorsForTest {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
271 virtual ~IGeneratorsForTest();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
272
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
273 virtual IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
274 virtual bool moveNext() = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
275 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
276
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
277 IGeneratorsForTest* createGeneratorsForTest();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
278
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
279 } // end namespace Catch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
280
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
281 // #included from: catch_ptr.hpp
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
282 #define TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
283
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
284 #ifdef __clang__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
285 #pragma clang diagnostic push
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
286 #pragma clang diagnostic ignored "-Wpadded"
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
287 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
288
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
289 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
290
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
291 // An intrusive reference counting smart pointer.
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
292 // T must implement addRef() and release() methods
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
293 // typically implementing the IShared interface
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
294 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
295 class Ptr {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
296 public:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
297 Ptr() : m_p( NULL ){}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
298 Ptr( T* p ) : m_p( p ){
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
299 if( m_p )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
300 m_p->addRef();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
301 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
302 Ptr( Ptr const& other ) : m_p( other.m_p ){
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
303 if( m_p )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
304 m_p->addRef();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
305 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
306 ~Ptr(){
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
307 if( m_p )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
308 m_p->release();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
309 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
310 void reset() {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
311 if( m_p )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
312 m_p->release();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
313 m_p = NULL;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
314 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
315 Ptr& operator = ( T* p ){
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
316 Ptr temp( p );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
317 swap( temp );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
318 return *this;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
319 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
320 Ptr& operator = ( Ptr const& other ){
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
321 Ptr temp( other );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
322 swap( temp );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
323 return *this;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
324 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
325 void swap( Ptr& other ) { std::swap( m_p, other.m_p ); }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
326 T* get() { return m_p; }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
327 const T* get() const{ return m_p; }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
328 T& operator*() const { return *m_p; }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
329 T* operator->() const { return m_p; }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
330 bool operator !() const { return m_p == NULL; }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
331 operator SafeBool::type() const { return SafeBool::makeSafe( m_p != NULL ); }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
332
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
333 private:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
334 T* m_p;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
335 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
336
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
337 struct IShared : NonCopyable {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
338 virtual ~IShared();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
339 virtual void addRef() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
340 virtual void release() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
341 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
342
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
343 template<typename T = IShared>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
344 struct SharedImpl : T {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
345
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
346 SharedImpl() : m_rc( 0 ){}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
347
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
348 virtual void addRef() const {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
349 ++m_rc;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
350 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
351 virtual void release() const {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
352 if( --m_rc == 0 )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
353 delete this;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
354 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
355
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
356 mutable unsigned int m_rc;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
357 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
358
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
359 } // end namespace Catch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
360
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
361 #ifdef __clang__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
362 #pragma clang diagnostic pop
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
363 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
364
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
365 #include <memory>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
366 #include <vector>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
367 #include <stdlib.h>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
368
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
369 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
370
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
371 class TestCase;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
372 class Stream;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
373 struct IResultCapture;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
374 struct IRunner;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
375 struct IGeneratorsForTest;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
376 struct IConfig;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
377
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
378 struct IContext
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
379 {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
380 virtual ~IContext();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
381
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
382 virtual IResultCapture& getResultCapture() = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
383 virtual IRunner& getRunner() = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
384 virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
385 virtual bool advanceGeneratorsForCurrentTest() = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
386 virtual Ptr<IConfig const> getConfig() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
387 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
388
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
389 struct IMutableContext : IContext
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
390 {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
391 virtual ~IMutableContext();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
392 virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
393 virtual void setRunner( IRunner* runner ) = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
394 virtual void setConfig( Ptr<IConfig const> const& config ) = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
395 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
396
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
397 IContext& getCurrentContext();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
398 IMutableContext& getCurrentMutableContext();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
399 void cleanUpContext();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
400 Stream createStream( std::string const& streamName );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
401
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
402 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
403
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
404 // #included from: internal/catch_test_registry.hpp
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
405 #define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
406
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
407 // #included from: catch_interfaces_testcase.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
408 #define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
409
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
410 #include <vector>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
411
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
412 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
413
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
414 class TestCaseFilters;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
415
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
416 struct ITestCase : IShared {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
417 virtual void invoke () const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
418 protected:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
419 virtual ~ITestCase();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
420 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
421
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
422 class TestCase;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
423
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
424 struct ITestCaseRegistry {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
425 virtual ~ITestCaseRegistry();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
426 virtual std::vector<TestCase> const& getAllTests() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
427 virtual std::vector<TestCase> getMatchingTestCases( std::string const& rawTestSpec ) const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
428 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
429 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
430
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
431 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
432
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
433 template<typename C>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
434 class MethodTestCase : public SharedImpl<ITestCase> {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
435
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
436 public:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
437 MethodTestCase( void (C::*method)() ) : m_method( method ) {}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
438
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
439 virtual void invoke() const {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
440 C obj;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
441 (obj.*m_method)();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
442 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
443
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
444 private:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
445 virtual ~MethodTestCase() {}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
446
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
447 void (C::*m_method)();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
448 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
449
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
450 typedef void(*TestFunction)();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
451
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
452 struct NameAndDesc {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
453 NameAndDesc( const char* _name = "", const char* _description= "" )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
454 : name( _name ), description( _description )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
455 {}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
456
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
457 const char* name;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
458 const char* description;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
459 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
460
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
461 struct AutoReg {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
462
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
463 AutoReg( TestFunction function,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
464 SourceLineInfo const& lineInfo,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
465 NameAndDesc const& nameAndDesc );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
466
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
467 template<typename C>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
468 AutoReg( void (C::*method)(),
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
469 char const* className,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
470 NameAndDesc const& nameAndDesc,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
471 SourceLineInfo const& lineInfo ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
472 registerTestCase( new MethodTestCase<C>( method ),
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
473 className,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
474 nameAndDesc,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
475 lineInfo );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
476 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
477
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
478 void registerTestCase( ITestCase* testCase,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
479 char const* className,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
480 NameAndDesc const& nameAndDesc,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
481 SourceLineInfo const& lineInfo );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
482
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
483 ~AutoReg();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
484
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
485 private:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
486 AutoReg( AutoReg const& );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
487 void operator= ( AutoReg const& );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
488 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
489
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
490 } // end namespace Catch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
491
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
492 #ifdef CATCH_CONFIG_VARIADIC_MACROS
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
493 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
494 #define INTERNAL_CATCH_TESTCASE( ... ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
495 static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )(); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
496 namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); }\
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
497 static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )()
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
498
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
499 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
500 #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
501 namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
502
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
503 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
504 #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... )\
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
505 namespace{ \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
506 struct INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) : ClassName{ \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
507 void test(); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
508 }; \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
509 Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
510 } \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
511 void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test()
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
512
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
513 #else
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
514 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
515 #define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
516 static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )(); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
517 namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
518 static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )()
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
519
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
520 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
521 #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
522 namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
523
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
524 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
525 #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
526 namespace{ \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
527 struct INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) : ClassName{ \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
528 void test(); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
529 }; \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
530 Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
531 } \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
532 void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test()
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
533
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
534 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
535
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
536 // #included from: internal/catch_capture.hpp
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
537 #define TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
538
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
539 // #included from: catch_expression_decomposer.hpp
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
540 #define TWOBLUECUBES_CATCH_EXPRESSION_DECOMPOSER_HPP_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
541
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
542 // #included from: catch_expression_lhs.hpp
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
543 #define TWOBLUECUBES_CATCH_EXPRESSION_LHS_HPP_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
544
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
545 // #included from: catch_expressionresult_builder.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
546 #define TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
547
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
548 // #included from: catch_tostring.hpp
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
549 #define TWOBLUECUBES_CATCH_TOSTRING_HPP_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
550
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
551 // #included from: catch_sfinae.hpp
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
552 #define TWOBLUECUBES_CATCH_SFINAE_HPP_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
553
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
554 // Try to detect if the current compiler supports SFINAE
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
555
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
556 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
557
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
558 struct TrueType {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
559 static const bool value = true;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
560 typedef void Enable;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
561 char sizer[1];
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
562 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
563 struct FalseType {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
564 static const bool value = false;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
565 typedef void Disable;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
566 char sizer[2];
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
567 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
568
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
569 #ifdef CATCH_CONFIG_SFINAE
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
570
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
571 template<bool> struct NotABooleanExpression;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
572
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
573 template<bool c> struct If : NotABooleanExpression<c> {};
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
574 template<> struct If<true> : TrueType {};
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
575 template<> struct If<false> : FalseType {};
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
576
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
577 template<int size> struct SizedIf;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
578 template<> struct SizedIf<sizeof(TrueType)> : TrueType {};
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
579 template<> struct SizedIf<sizeof(FalseType)> : FalseType {};
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
580
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
581 #endif // CATCH_CONFIG_SFINAE
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
582
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
583 } // end namespace Catch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
584
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
585 #include <sstream>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
586 #include <iomanip>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
587 #include <limits>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
588 #include <vector>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
589
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
590 #ifdef __OBJC__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
591 // #included from: catch_objc_arc.hpp
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
592 #define TWOBLUECUBES_CATCH_OBJC_ARC_HPP_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
593
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
594 #import <Foundation/Foundation.h>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
595
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
596 #ifdef __has_feature
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
597 #define CATCH_ARC_ENABLED __has_feature(objc_arc)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
598 #else
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
599 #define CATCH_ARC_ENABLED 0
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
600 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
601
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
602 void arcSafeRelease( NSObject* obj );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
603 id performOptionalSelector( id obj, SEL sel );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
604
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
605 #if !CATCH_ARC_ENABLED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
606 inline void arcSafeRelease( NSObject* obj ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
607 [obj release];
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
608 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
609 inline id performOptionalSelector( id obj, SEL sel ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
610 if( [obj respondsToSelector: sel] )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
611 return [obj performSelector: sel];
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
612 return nil;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
613 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
614 #define CATCH_UNSAFE_UNRETAINED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
615 #define CATCH_ARC_STRONG
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
616 #else
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
617 inline void arcSafeRelease( NSObject* ){}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
618 inline id performOptionalSelector( id obj, SEL sel ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
619 #ifdef __clang__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
620 #pragma clang diagnostic push
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
621 #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
622 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
623 if( [obj respondsToSelector: sel] )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
624 return [obj performSelector: sel];
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
625 #ifdef __clang__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
626 #pragma clang diagnostic pop
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
627 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
628 return nil;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
629 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
630 #define CATCH_UNSAFE_UNRETAINED __unsafe_unretained
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
631 #define CATCH_ARC_STRONG __strong
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
632 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
633
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
634 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
635
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
636 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
637 namespace Detail {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
638
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
639 // SFINAE is currently disabled by default for all compilers.
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
640 // If the non SFINAE version of IsStreamInsertable is ambiguous for you
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
641 // and your compiler supports SFINAE, try #defining CATCH_CONFIG_SFINAE
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
642 #ifdef CATCH_CONFIG_SFINAE
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
643
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
644 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
645 class IsStreamInsertableHelper {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
646 template<int N> struct TrueIfSizeable : TrueType {};
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
647
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
648 template<typename T2>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
649 static TrueIfSizeable<sizeof((*(std::ostream*)0) << *((T2 const*)0))> dummy(T2*);
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
650 static FalseType dummy(...);
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
651
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
652 public:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
653 typedef SizedIf<sizeof(dummy((T*)0))> type;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
654 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
655
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
656 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
657 struct IsStreamInsertable : IsStreamInsertableHelper<T>::type {};
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
658
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
659 #else
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
660
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
661 struct BorgType {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
662 template<typename T> BorgType( T const& );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
663 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
664
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
665 TrueType& testStreamable( std::ostream& );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
666 FalseType testStreamable( FalseType );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
667
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
668 FalseType operator<<( std::ostream const&, BorgType const& );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
669
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
670 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
671 struct IsStreamInsertable {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
672 static std::ostream &s;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
673 static T const&t;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
674 enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
675 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
676
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
677 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
678
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
679 template<bool C>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
680 struct StringMakerBase {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
681 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
682 static std::string convert( T const& ) { return "{?}"; }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
683 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
684
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
685 template<>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
686 struct StringMakerBase<true> {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
687 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
688 static std::string convert( T const& _value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
689 std::ostringstream oss;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
690 oss << _value;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
691 return oss.str();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
692 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
693 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
694
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
695 // For display purposes only.
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
696 // Does not consider endian-ness
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
697 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
698 std::string rawMemoryToString( T value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
699 union {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
700 T typedValue;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
701 unsigned char bytes[sizeof(T)];
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
702 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
703
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
704 typedValue = value;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
705
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
706 std::ostringstream oss;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
707 oss << "0x";
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
708 for( unsigned char* cp = bytes; cp < bytes+sizeof(T); ++cp )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
709 oss << std::hex << std::setw(2) << std::setfill('0') << (unsigned int)*cp;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
710 return oss.str();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
711 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
712
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
713 } // end namespace Detail
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
714
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
715 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
716 std::string toString( T const& value );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
717
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
718 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
719 struct StringMaker :
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
720 Detail::StringMakerBase<Detail::IsStreamInsertable<T>::value> {};
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
721
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
722 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
723 struct StringMaker<T*> {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
724 template<typename U>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
725 static std::string convert( U* p ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
726 if( !p )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
727 return INTERNAL_CATCH_STRINGIFY( NULL );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
728 else
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
729 return Detail::rawMemoryToString( p );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
730 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
731 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
732
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
733 template<typename R, typename C>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
734 struct StringMaker<R C::*> {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
735 static std::string convert( R C::* p ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
736 if( !p )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
737 return INTERNAL_CATCH_STRINGIFY( NULL );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
738 else
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
739 return Detail::rawMemoryToString( p );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
740 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
741 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
742
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
743 namespace Detail {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
744 template<typename InputIterator>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
745 std::string rangeToString( InputIterator first, InputIterator last );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
746 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
747
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
748 template<typename T, typename Allocator>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
749 struct StringMaker<std::vector<T, Allocator> > {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
750 static std::string convert( std::vector<T,Allocator> const& v ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
751 return Detail::rangeToString( v.begin(), v.end() );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
752 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
753 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
754
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
755 namespace Detail {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
756 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
757 inline std::string makeString( T const& value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
758 return StringMaker<T>::convert( value );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
759 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
760 } // end namespace Detail
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
761
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
762 /// \brief converts any type to a string
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
763 ///
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
764 /// The default template forwards on to ostringstream - except when an
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
765 /// ostringstream overload does not exist - in which case it attempts to detect
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
766 /// that and writes {?}.
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
767 /// Overload (not specialise) this template for custom typs that you don't want
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
768 /// to provide an ostream overload for.
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
769 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
770 std::string toString( T const& value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
771 return StringMaker<T>::convert( value );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
772 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
773
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
774 // Built in overloads
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
775
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
776 inline std::string toString( std::string const& value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
777 return "\"" + value + "\"";
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
778 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
779
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
780 inline std::string toString( std::wstring const& value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
781 std::ostringstream oss;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
782 oss << "\"";
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
783 for(size_t i = 0; i < value.size(); ++i )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
784 oss << static_cast<char>( value[i] <= 0xff ? value[i] : '?');
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
785 oss << "\"";
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
786 return oss.str();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
787 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
788
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
789 inline std::string toString( const char* const value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
790 return value ? Catch::toString( std::string( value ) ) : std::string( "{null string}" );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
791 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
792
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
793 inline std::string toString( char* const value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
794 return Catch::toString( static_cast<const char*>( value ) );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
795 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
796
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
797 inline std::string toString( int value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
798 std::ostringstream oss;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
799 oss << value;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
800 return oss.str();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
801 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
802
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
803 inline std::string toString( unsigned long value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
804 std::ostringstream oss;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
805 if( value > 8192 )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
806 oss << "0x" << std::hex << value;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
807 else
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
808 oss << value;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
809 return oss.str();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
810 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
811
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
812 inline std::string toString( unsigned int value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
813 return toString( static_cast<unsigned long>( value ) );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
814 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
815
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
816 inline std::string toString( const double value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
817 std::ostringstream oss;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
818 oss << std::setprecision( 10 )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
819 << std::fixed
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
820 << value;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
821 std::string d = oss.str();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
822 std::size_t i = d.find_last_not_of( '0' );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
823 if( i != std::string::npos && i != d.size()-1 ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
824 if( d[i] == '.' )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
825 i++;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
826 d = d.substr( 0, i+1 );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
827 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
828 return d;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
829 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
830
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
831 inline std::string toString( bool value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
832 return value ? "true" : "false";
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
833 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
834
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
835 inline std::string toString( char value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
836 return value < ' '
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
837 ? toString( static_cast<unsigned int>( value ) )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
838 : Detail::makeString( value );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
839 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
840
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
841 inline std::string toString( signed char value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
842 return toString( static_cast<char>( value ) );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
843 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
844
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
845 inline std::string toString( unsigned char value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
846 return toString( static_cast<char>( value ) );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
847 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
848
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
849 #ifdef CATCH_CONFIG_CPP11_NULLPTR
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
850 inline std::string toString( std::nullptr_t ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
851 return "nullptr";
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
852 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
853 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
854
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
855 #ifdef __OBJC__
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
856 inline std::string toString( NSString const * const& nsstring ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
857 if( !nsstring )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
858 return "nil";
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
859 return std::string( "@\"" ) + [nsstring UTF8String] + "\"";
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
860 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
861 inline std::string toString( NSString * CATCH_ARC_STRONG const& nsstring ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
862 if( !nsstring )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
863 return "nil";
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
864 return std::string( "@\"" ) + [nsstring UTF8String] + "\"";
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
865 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
866 inline std::string toString( NSObject* const& nsObject ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
867 return toString( [nsObject description] );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
868 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
869 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
870
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
871 namespace Detail {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
872 template<typename InputIterator>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
873 std::string rangeToString( InputIterator first, InputIterator last ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
874 std::ostringstream oss;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
875 oss << "{ ";
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
876 if( first != last ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
877 oss << toString( *first );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
878 for( ++first ; first != last ; ++first ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
879 oss << ", " << toString( *first );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
880 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
881 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
882 oss << " }";
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
883 return oss.str();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
884 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
885 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
886
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
887 } // end namespace Catch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
888
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
889 // #included from: catch_assertionresult.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
890 #define TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
891
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
892 #include <string>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
893 // #included from: catch_result_type.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
894 #define TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
895
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
896 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
897
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
898 // ResultWas::OfType enum
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
899 struct ResultWas { enum OfType {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
900 Unknown = -1,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
901 Ok = 0,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
902 Info = 1,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
903 Warning = 2,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
904
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
905 FailureBit = 0x10,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
906
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
907 ExpressionFailed = FailureBit | 1,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
908 ExplicitFailure = FailureBit | 2,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
909
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
910 Exception = 0x100 | FailureBit,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
911
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
912 ThrewException = Exception | 1,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
913 DidntThrowException = Exception | 2
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
914
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
915 }; };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
916
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
917 inline bool isOk( ResultWas::OfType resultType ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
918 return ( resultType & ResultWas::FailureBit ) == 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
919 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
920 inline bool isJustInfo( int flags ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
921 return flags == ResultWas::Info;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
922 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
923
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
924 // ResultAction::Value enum
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
925 struct ResultAction { enum Value {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
926 None,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
927 Failed = 1, // Failure - but no debug break if Debug bit not set
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
928 Debug = 2, // If this bit is set, invoke the debugger
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
929 Abort = 4 // Test run should abort
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
930 }; };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
931
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
932 // ResultDisposition::Flags enum
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
933 struct ResultDisposition { enum Flags {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
934 Normal = 0x00,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
935
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
936 ContinueOnFailure = 0x01, // Failures fail test, but execution continues
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
937 NegateResult = 0x02, // Prefix expressiom with !
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
938 SuppressFail = 0x04 // Failures are reported but do not fail the test
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
939 }; };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
940
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
941 inline ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
942 return static_cast<ResultDisposition::Flags>( static_cast<int>( lhs ) | static_cast<int>( rhs ) );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
943 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
944
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
945 inline bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
946 inline bool shouldNegate( int flags ) { return ( flags & ResultDisposition::NegateResult ) != 0; }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
947 inline bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
948
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
949 } // end namespace Catch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
950
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
951
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
952 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
953
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
954 struct AssertionInfo
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
955 {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
956 AssertionInfo() {}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
957 AssertionInfo( std::string const& _macroName,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
958 SourceLineInfo const& _lineInfo,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
959 std::string const& _capturedExpression,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
960 ResultDisposition::Flags _resultDisposition );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
961
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
962 std::string macroName;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
963 SourceLineInfo lineInfo;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
964 std::string capturedExpression;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
965 ResultDisposition::Flags resultDisposition;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
966 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
967
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
968 struct AssertionResultData
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
969 {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
970 AssertionResultData() : resultType( ResultWas::Unknown ) {}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
971
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
972 std::string reconstructedExpression;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
973 std::string message;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
974 ResultWas::OfType resultType;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
975 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
976
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
977 class AssertionResult {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
978 public:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
979 AssertionResult();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
980 AssertionResult( AssertionInfo const& info, AssertionResultData const& data );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
981 ~AssertionResult();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
982
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
983 bool isOk() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
984 bool succeeded() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
985 ResultWas::OfType getResultType() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
986 bool hasExpression() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
987 bool hasMessage() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
988 std::string getExpression() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
989 std::string getExpressionInMacro() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
990 bool hasExpandedExpression() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
991 std::string getExpandedExpression() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
992 std::string getMessage() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
993 SourceLineInfo getSourceInfo() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
994 std::string getTestMacroName() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
995
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
996 protected:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
997 AssertionInfo m_info;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
998 AssertionResultData m_resultData;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
999 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1000
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1001 } // end namespace Catch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1002
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1003 // #included from: catch_evaluate.hpp
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1004 #define TWOBLUECUBES_CATCH_EVALUATE_HPP_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1005
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1006 #ifdef _MSC_VER
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1007 #pragma warning(push)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1008 #pragma warning(disable:4389) // '==' : signed/unsigned mismatch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1009 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1010
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1011 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1012 namespace Internal {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1013
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1014 enum Operator {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1015 IsEqualTo,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1016 IsNotEqualTo,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1017 IsLessThan,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1018 IsGreaterThan,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1019 IsLessThanOrEqualTo,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1020 IsGreaterThanOrEqualTo
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1021 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1022
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1023 template<Operator Op> struct OperatorTraits { static const char* getName(){ return "*error*"; } };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1024 template<> struct OperatorTraits<IsEqualTo> { static const char* getName(){ return "=="; } };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1025 template<> struct OperatorTraits<IsNotEqualTo> { static const char* getName(){ return "!="; } };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1026 template<> struct OperatorTraits<IsLessThan> { static const char* getName(){ return "<"; } };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1027 template<> struct OperatorTraits<IsGreaterThan> { static const char* getName(){ return ">"; } };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1028 template<> struct OperatorTraits<IsLessThanOrEqualTo> { static const char* getName(){ return "<="; } };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1029 template<> struct OperatorTraits<IsGreaterThanOrEqualTo>{ static const char* getName(){ return ">="; } };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1030
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1031 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1032 inline T& opCast(T const& t) { return const_cast<T&>(t); }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1033
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1034 // nullptr_t support based on pull request #154 from Konstantin Baumann
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1035 #ifdef CATCH_CONFIG_CPP11_NULLPTR
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1036 inline std::nullptr_t opCast(std::nullptr_t) { return nullptr; }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1037 #endif // CATCH_CONFIG_CPP11_NULLPTR
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1038
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1039 // So the compare overloads can be operator agnostic we convey the operator as a template
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1040 // enum, which is used to specialise an Evaluator for doing the comparison.
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1041 template<typename T1, typename T2, Operator Op>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1042 class Evaluator{};
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1043
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1044 template<typename T1, typename T2>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1045 struct Evaluator<T1, T2, IsEqualTo> {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1046 static bool evaluate( T1 const& lhs, T2 const& rhs) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1047 return opCast( lhs ) == opCast( rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1048 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1049 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1050 template<typename T1, typename T2>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1051 struct Evaluator<T1, T2, IsNotEqualTo> {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1052 static bool evaluate( T1 const& lhs, T2 const& rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1053 return opCast( lhs ) != opCast( rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1054 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1055 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1056 template<typename T1, typename T2>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1057 struct Evaluator<T1, T2, IsLessThan> {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1058 static bool evaluate( T1 const& lhs, T2 const& rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1059 return opCast( lhs ) < opCast( rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1060 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1061 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1062 template<typename T1, typename T2>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1063 struct Evaluator<T1, T2, IsGreaterThan> {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1064 static bool evaluate( T1 const& lhs, T2 const& rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1065 return opCast( lhs ) > opCast( rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1066 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1067 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1068 template<typename T1, typename T2>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1069 struct Evaluator<T1, T2, IsGreaterThanOrEqualTo> {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1070 static bool evaluate( T1 const& lhs, T2 const& rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1071 return opCast( lhs ) >= opCast( rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1072 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1073 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1074 template<typename T1, typename T2>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1075 struct Evaluator<T1, T2, IsLessThanOrEqualTo> {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1076 static bool evaluate( T1 const& lhs, T2 const& rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1077 return opCast( lhs ) <= opCast( rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1078 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1079 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1080
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1081 template<Operator Op, typename T1, typename T2>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1082 bool applyEvaluator( T1 const& lhs, T2 const& rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1083 return Evaluator<T1, T2, Op>::evaluate( lhs, rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1084 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1085
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1086 // This level of indirection allows us to specialise for integer types
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1087 // to avoid signed/ unsigned warnings
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1088
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1089 // "base" overload
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1090 template<Operator Op, typename T1, typename T2>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1091 bool compare( T1 const& lhs, T2 const& rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1092 return Evaluator<T1, T2, Op>::evaluate( lhs, rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1093 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1094
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1095 // unsigned X to int
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1096 template<Operator Op> bool compare( unsigned int lhs, int rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1097 return applyEvaluator<Op>( lhs, static_cast<unsigned int>( rhs ) );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1098 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1099 template<Operator Op> bool compare( unsigned long lhs, int rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1100 return applyEvaluator<Op>( lhs, static_cast<unsigned int>( rhs ) );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1101 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1102 template<Operator Op> bool compare( unsigned char lhs, int rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1103 return applyEvaluator<Op>( lhs, static_cast<unsigned int>( rhs ) );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1104 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1105
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1106 // unsigned X to long
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1107 template<Operator Op> bool compare( unsigned int lhs, long rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1108 return applyEvaluator<Op>( lhs, static_cast<unsigned long>( rhs ) );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1109 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1110 template<Operator Op> bool compare( unsigned long lhs, long rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1111 return applyEvaluator<Op>( lhs, static_cast<unsigned long>( rhs ) );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1112 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1113 template<Operator Op> bool compare( unsigned char lhs, long rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1114 return applyEvaluator<Op>( lhs, static_cast<unsigned long>( rhs ) );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1115 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1116
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1117 // int to unsigned X
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1118 template<Operator Op> bool compare( int lhs, unsigned int rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1119 return applyEvaluator<Op>( static_cast<unsigned int>( lhs ), rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1120 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1121 template<Operator Op> bool compare( int lhs, unsigned long rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1122 return applyEvaluator<Op>( static_cast<unsigned int>( lhs ), rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1123 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1124 template<Operator Op> bool compare( int lhs, unsigned char rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1125 return applyEvaluator<Op>( static_cast<unsigned int>( lhs ), rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1126 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1127
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1128 // long to unsigned X
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1129 template<Operator Op> bool compare( long lhs, unsigned int rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1130 return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1131 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1132 template<Operator Op> bool compare( long lhs, unsigned long rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1133 return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1134 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1135 template<Operator Op> bool compare( long lhs, unsigned char rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1136 return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1137 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1138
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1139 // pointer to long (when comparing against NULL)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1140 template<Operator Op, typename T> bool compare( long lhs, T* rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1141 return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1142 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1143 template<Operator Op, typename T> bool compare( T* lhs, long rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1144 return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1145 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1146
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1147 // pointer to int (when comparing against NULL)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1148 template<Operator Op, typename T> bool compare( int lhs, T* rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1149 return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1150 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1151 template<Operator Op, typename T> bool compare( T* lhs, int rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1152 return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1153 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1154
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1155 #ifdef CATCH_CONFIG_CPP11_NULLPTR
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1156 // pointer to nullptr_t (when comparing against nullptr)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1157 template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1158 return Evaluator<T*, T*, Op>::evaluate( NULL, rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1159 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1160 template<Operator Op, typename T> bool compare( T* lhs, std::nullptr_t ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1161 return Evaluator<T*, T*, Op>::evaluate( lhs, NULL );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1162 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1163 #endif // CATCH_CONFIG_CPP11_NULLPTR
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1164
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1165 } // end of namespace Internal
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1166 } // end of namespace Catch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1167
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1168 #ifdef _MSC_VER
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1169 #pragma warning(pop)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1170 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1171
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1172 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1173
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1174 struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1175
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1176 // Wraps the (stringised versions of) the lhs, operator and rhs of an expression - as well as
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1177 // the result of evaluating it. This is used to build an AssertionResult object
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1178 class ExpressionResultBuilder {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1179 public:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1180
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1181 ExpressionResultBuilder( ResultWas::OfType resultType = ResultWas::Unknown );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1182 ExpressionResultBuilder( ExpressionResultBuilder const& other );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1183 ExpressionResultBuilder& operator=(ExpressionResultBuilder const& other );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1184
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1185 ExpressionResultBuilder& setResultType( ResultWas::OfType result );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1186 ExpressionResultBuilder& setResultType( bool result );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1187 ExpressionResultBuilder& setLhs( std::string const& lhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1188 ExpressionResultBuilder& setRhs( std::string const& rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1189 ExpressionResultBuilder& setOp( std::string const& op );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1190
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1191 ExpressionResultBuilder& endExpression( ResultDisposition::Flags resultDisposition );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1192
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1193 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1194 ExpressionResultBuilder& operator << ( T const& value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1195 m_stream << value;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1196 return *this;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1197 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1198
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1199 std::string reconstructExpression( AssertionInfo const& info ) const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1200
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1201 AssertionResult buildResult( AssertionInfo const& info ) const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1202
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1203 template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( RhsT const& );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1204 template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( RhsT const& );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1205
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1206 private:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1207 AssertionResultData m_data;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1208 struct ExprComponents {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1209 ExprComponents() : shouldNegate( false ) {}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1210 bool shouldNegate;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1211 std::string lhs, rhs, op;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1212 } m_exprComponents;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1213 std::ostringstream m_stream;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1214 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1215
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1216 } // end namespace Catch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1217
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1218 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1219
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1220 // Wraps the LHS of an expression and captures the operator and RHS (if any) - wrapping them all
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1221 // in an ExpressionResultBuilder object
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1222 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1223 class ExpressionLhs {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1224 void operator = ( ExpressionLhs const& );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1225
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1226 public:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1227 ExpressionLhs( T lhs ) : m_lhs( lhs ) {}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1228
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1229 template<typename RhsT>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1230 ExpressionResultBuilder& operator == ( RhsT const& rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1231 return captureExpression<Internal::IsEqualTo>( rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1232 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1233
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1234 template<typename RhsT>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1235 ExpressionResultBuilder& operator != ( RhsT const& rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1236 return captureExpression<Internal::IsNotEqualTo>( rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1237 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1238
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1239 template<typename RhsT>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1240 ExpressionResultBuilder& operator < ( RhsT const& rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1241 return captureExpression<Internal::IsLessThan>( rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1242 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1243
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1244 template<typename RhsT>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1245 ExpressionResultBuilder& operator > ( RhsT const& rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1246 return captureExpression<Internal::IsGreaterThan>( rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1247 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1248
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1249 template<typename RhsT>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1250 ExpressionResultBuilder& operator <= ( RhsT const& rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1251 return captureExpression<Internal::IsLessThanOrEqualTo>( rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1252 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1253
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1254 template<typename RhsT>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1255 ExpressionResultBuilder& operator >= ( RhsT const& rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1256 return captureExpression<Internal::IsGreaterThanOrEqualTo>( rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1257 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1258
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1259 ExpressionResultBuilder& operator == ( bool rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1260 return captureExpression<Internal::IsEqualTo>( rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1261 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1262
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1263 ExpressionResultBuilder& operator != ( bool rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1264 return captureExpression<Internal::IsNotEqualTo>( rhs );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1265 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1266
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1267 ExpressionResultBuilder& endExpression( ResultDisposition::Flags resultDisposition ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1268 bool value = m_lhs ? true : false;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1269 return m_result
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1270 .setLhs( Catch::toString( value ) )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1271 .setResultType( value )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1272 .endExpression( resultDisposition );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1273 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1274
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1275 // Only simple binary expressions are allowed on the LHS.
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1276 // If more complex compositions are required then place the sub expression in parentheses
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1277 template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator + ( RhsT const& );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1278 template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator - ( RhsT const& );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1279 template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator / ( RhsT const& );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1280 template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator * ( RhsT const& );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1281 template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( RhsT const& );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1282 template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( RhsT const& );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1283
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1284 private:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1285 template<Internal::Operator Op, typename RhsT>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1286 ExpressionResultBuilder& captureExpression( RhsT const& rhs ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1287 return m_result
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1288 .setResultType( Internal::compare<Op>( m_lhs, rhs ) )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1289 .setLhs( Catch::toString( m_lhs ) )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1290 .setRhs( Catch::toString( rhs ) )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1291 .setOp( Internal::OperatorTraits<Op>::getName() );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1292 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1293
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1294 private:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1295 ExpressionResultBuilder m_result;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1296 T m_lhs;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1297 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1298
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1299 } // end namespace Catch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1300
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1301 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1302
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1303 // Captures the LHS of the expression and wraps it in an Expression Lhs object
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1304 class ExpressionDecomposer {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1305 public:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1306
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1307 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1308 ExpressionLhs<T const&> operator->* ( T const& operand ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1309 return ExpressionLhs<T const&>( operand );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1310 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1311
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1312 ExpressionLhs<bool> operator->* ( bool value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1313 return ExpressionLhs<bool>( value );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1314 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1315 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1316
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1317 } // end namespace Catch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1318
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1319 // #included from: catch_message.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1320 #define TWOBLUECUBES_CATCH_MESSAGE_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1321
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1322 #include <string>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1323
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1324 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1325
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1326 struct MessageInfo {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1327 MessageInfo( std::string const& _macroName,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1328 SourceLineInfo const& _lineInfo,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1329 ResultWas::OfType _type );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1330
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1331 std::string macroName;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1332 SourceLineInfo lineInfo;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1333 ResultWas::OfType type;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1334 std::string message;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1335 unsigned int sequence;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1336
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1337 bool operator == ( MessageInfo const& other ) const {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1338 return sequence == other.sequence;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1339 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1340 bool operator < ( MessageInfo const& other ) const {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1341 return sequence < other.sequence;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1342 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1343 private:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1344 static unsigned int globalCount;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1345 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1346
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1347 struct MessageBuilder {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1348 MessageBuilder( std::string const& macroName,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1349 SourceLineInfo const& lineInfo,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1350 ResultWas::OfType type )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1351 : m_info( macroName, lineInfo, type )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1352 {}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1353
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1354 template<typename T>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1355 MessageBuilder& operator << ( T const& value ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1356 m_stream << value;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1357 return *this;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1358 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1359
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1360 MessageInfo m_info;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1361 std::ostringstream m_stream;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1362 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1363
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1364 class ScopedMessage {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1365 public:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1366 ScopedMessage( MessageBuilder const& builder );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1367 ~ScopedMessage();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1368
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1369 MessageInfo m_info;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1370 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1371
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1372 } // end namespace Catch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1373
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1374 // #included from: catch_interfaces_capture.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1375 #define TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1376
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1377 #include <string>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1378
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1379 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1380
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1381 class TestCase;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1382 class ExpressionResultBuilder;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1383 class AssertionResult;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1384 struct AssertionInfo;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1385 struct SectionInfo;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1386 struct MessageInfo;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1387 class ScopedMessageBuilder;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1388 struct Counts;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1389
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1390 struct IResultCapture {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1391
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1392 virtual ~IResultCapture();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1393
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1394 virtual void assertionEnded( AssertionResult const& result ) = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1395 virtual bool sectionStarted( SectionInfo const& sectionInfo,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1396 Counts& assertions ) = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1397 virtual void sectionEnded( SectionInfo const& name, Counts const& assertions, double _durationInSeconds ) = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1398 virtual void pushScopedMessage( MessageInfo const& message ) = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1399 virtual void popScopedMessage( MessageInfo const& message ) = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1400
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1401 virtual bool shouldDebugBreak() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1402
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1403 virtual ResultAction::Value acceptExpression( ExpressionResultBuilder const& assertionResult, AssertionInfo const& assertionInfo ) = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1404
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1405 virtual std::string getCurrentTestName() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1406 virtual const AssertionResult* getLastResult() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1407 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1408 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1409
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1410 // #included from: catch_debugger.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1411 #define TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1412
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1413 // #included from: catch_platform.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1414 #define TWOBLUECUBES_CATCH_PLATFORM_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1415
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1416 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1417 #define CATCH_PLATFORM_MAC
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1418 #elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1419 #define CATCH_PLATFORM_IPHONE
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1420 #elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1421 #define CATCH_PLATFORM_WINDOWS
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1422 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1423
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1424 #include <string>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1425
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1426 namespace Catch{
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1427
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1428 bool isDebuggerActive();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1429 void writeToDebugConsole( std::string const& text );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1430 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1431
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1432 #ifdef CATCH_PLATFORM_MAC
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1433
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1434 // The following code snippet based on:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1435 // http://cocoawithlove.com/2008/03/break-into-debugger.html
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1436 #ifdef DEBUG
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1437 #if defined(__ppc64__) || defined(__ppc__)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1438 #define CATCH_BREAK_INTO_DEBUGGER() \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1439 if( Catch::isDebuggerActive() ) { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1440 __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1441 : : : "memory","r0","r3","r4" ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1442 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1443 #else
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1444 #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) {__asm__("int $3\n" : : );}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1445 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1446 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1447
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1448 #elif defined(_MSC_VER)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1449 #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { __debugbreak(); }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1450 #elif defined(__MINGW32__)
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1451 extern "C" __declspec(dllimport) void __stdcall DebugBreak();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1452 #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { DebugBreak(); }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1453 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1454
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1455 #ifndef CATCH_BREAK_INTO_DEBUGGER
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1456 #define CATCH_BREAK_INTO_DEBUGGER() Catch::isTrue( true );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1457 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1458
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1459 // #included from: catch_interfaces_registry_hub.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1460 #define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1461
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1462 #include <string>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1463
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1464 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1465
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1466 class TestCase;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1467 struct ITestCaseRegistry;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1468 struct IExceptionTranslatorRegistry;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1469 struct IExceptionTranslator;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1470 struct IReporterRegistry;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1471 struct IReporterFactory;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1472
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1473 struct IRegistryHub {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1474 virtual ~IRegistryHub();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1475
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1476 virtual IReporterRegistry const& getReporterRegistry() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1477 virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1478 virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1479 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1480
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1481 struct IMutableRegistryHub {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1482 virtual ~IMutableRegistryHub();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1483 virtual void registerReporter( std::string const& name, IReporterFactory* factory ) = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1484 virtual void registerTest( TestCase const& testInfo ) = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1485 virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1486 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1487
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1488 IRegistryHub& getRegistryHub();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1489 IMutableRegistryHub& getMutableRegistryHub();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1490 void cleanUp();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1491 std::string translateActiveException();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1492
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1493 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1494
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1495 // #included from: catch_interfaces_config.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1496 #define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1497
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1498 #include <iostream>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1499 #include <string>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1500
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1501 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1502
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1503 struct Verbosity { enum Level {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1504 NoOutput = 0,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1505 Quiet,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1506 Normal
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1507 }; };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1508
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1509 struct WarnAbout { enum What {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1510 Nothing = 0x00,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1511 NoAssertions = 0x01
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1512 }; };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1513
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1514 struct ShowDurations { enum OrNot {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1515 DefaultForReporter,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1516 Always,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1517 Never
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1518 }; };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1519
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1520 struct IConfig : IShared {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1521
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1522 virtual ~IConfig();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1523
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1524 virtual bool allowThrows() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1525 virtual std::ostream& stream() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1526 virtual std::string name() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1527 virtual bool includeSuccessfulResults() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1528 virtual bool shouldDebugBreak() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1529 virtual bool warnAboutMissingAssertions() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1530 virtual int abortAfter() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1531 virtual ShowDurations::OrNot showDurations() const = 0;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1532 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1533 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1534
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1535 #include <ostream>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1536
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1537 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1538
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1539 inline IResultCapture& getResultCapture() {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1540 return getCurrentContext().getResultCapture();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1541 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1542
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1543 template<typename MatcherT>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1544 ExpressionResultBuilder expressionResultBuilderFromMatcher( MatcherT const& matcher,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1545 std::string const& matcherCallAsString ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1546 std::string matcherAsString = matcher.toString();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1547 if( matcherAsString == "{?}" )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1548 matcherAsString = matcherCallAsString;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1549 return ExpressionResultBuilder()
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1550 .setRhs( matcherAsString )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1551 .setOp( "matches" );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1552 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1553
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1554 template<typename MatcherT, typename ArgT>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1555 ExpressionResultBuilder expressionResultBuilderFromMatcher( MatcherT const& matcher,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1556 ArgT const& arg,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1557 std::string const& matcherCallAsString ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1558 return expressionResultBuilderFromMatcher( matcher, matcherCallAsString )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1559 .setLhs( Catch::toString( arg ) )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1560 .setResultType( matcher.match( arg ) );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1561 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1562
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1563 template<typename MatcherT, typename ArgT>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1564 ExpressionResultBuilder expressionResultBuilderFromMatcher( MatcherT const& matcher,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1565 ArgT* arg,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1566 std::string const& matcherCallAsString ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1567 return expressionResultBuilderFromMatcher( matcher, matcherCallAsString )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1568 .setLhs( Catch::toString( arg ) )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1569 .setResultType( matcher.match( arg ) );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1570 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1571
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1572 struct TestFailureException{};
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1573
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1574 } // end namespace Catch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1575
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1576 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1577 #define INTERNAL_CATCH_ASSERTIONINFO_NAME INTERNAL_CATCH_UNIQUE_NAME( __assertionInfo )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1578
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1579 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1580 #define INTERNAL_CATCH_ACCEPT_EXPR( evaluatedExpr, resultDisposition, originalExpr ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1581 if( Catch::ResultAction::Value internal_catch_action = Catch::getResultCapture().acceptExpression( evaluatedExpr, INTERNAL_CATCH_ASSERTIONINFO_NAME ) ) { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1582 if( internal_catch_action & Catch::ResultAction::Debug ) CATCH_BREAK_INTO_DEBUGGER(); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1583 if( internal_catch_action & Catch::ResultAction::Abort ) throw Catch::TestFailureException(); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1584 if( !Catch::shouldContinueOnFailure( resultDisposition ) ) throw Catch::TestFailureException(); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1585 Catch::isTrue( false && originalExpr ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1586 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1587
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1588 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1589 #define INTERNAL_CATCH_ACCEPT_INFO( expr, macroName, resultDisposition ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1590 Catch::AssertionInfo INTERNAL_CATCH_ASSERTIONINFO_NAME( macroName, CATCH_INTERNAL_LINEINFO, expr, resultDisposition );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1591
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1592 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1593 #define INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1594 do { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1595 INTERNAL_CATCH_ACCEPT_INFO( #expr, macroName, resultDisposition ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1596 try { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1597 INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionDecomposer()->*expr ).endExpression( resultDisposition ), resultDisposition, expr ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1598 } catch( Catch::TestFailureException& ) { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1599 throw; \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1600 } catch( ... ) { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1601 INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1602 resultDisposition | Catch::ResultDisposition::ContinueOnFailure, expr ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1603 } \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1604 } while( Catch::isTrue( false ) )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1605
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1606 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1607 #define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1608 INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1609 if( Catch::getResultCapture().getLastResult()->succeeded() )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1610
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1611 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1612 #define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1613 INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1614 if( !Catch::getResultCapture().getLastResult()->succeeded() )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1615
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1616 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1617 #define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1618 do { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1619 INTERNAL_CATCH_ACCEPT_INFO( #expr, macroName, resultDisposition ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1620 try { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1621 expr; \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1622 INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::Ok ), resultDisposition, false ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1623 } \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1624 catch( ... ) { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1625 INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), resultDisposition, false ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1626 } \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1627 } while( Catch::isTrue( false ) )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1628
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1629 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1630 #define INTERNAL_CATCH_THROWS_IMPL( expr, exceptionType, resultDisposition ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1631 try { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1632 if( Catch::getCurrentContext().getConfig()->allowThrows() ) { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1633 expr; \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1634 INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::DidntThrowException ), resultDisposition, false ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1635 } \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1636 } \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1637 catch( Catch::TestFailureException& ) { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1638 throw; \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1639 } \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1640 catch( exceptionType ) { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1641 INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::Ok ), resultDisposition, false ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1642 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1643
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1644 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1645 #define INTERNAL_CATCH_THROWS( expr, exceptionType, resultDisposition, macroName ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1646 do { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1647 INTERNAL_CATCH_ACCEPT_INFO( #expr, macroName, resultDisposition ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1648 INTERNAL_CATCH_THROWS_IMPL( expr, exceptionType, resultDisposition ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1649 } while( Catch::isTrue( false ) )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1650
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1651 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1652 #define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, resultDisposition, macroName ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1653 do { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1654 INTERNAL_CATCH_ACCEPT_INFO( #expr, macroName, resultDisposition ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1655 INTERNAL_CATCH_THROWS_IMPL( expr, exceptionType, resultDisposition ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1656 catch( ... ) { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1657 INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException() ), \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1658 resultDisposition | Catch::ResultDisposition::ContinueOnFailure, false ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1659 } \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1660 } while( Catch::isTrue( false ) )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1661
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1662 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1663 #ifdef CATCH_CONFIG_VARIADIC_MACROS
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1664 #define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, ... ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1665 do { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1666 INTERNAL_CATCH_ACCEPT_INFO( "", macroName, resultDisposition ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1667 INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( messageType ) << __VA_ARGS__ +::Catch::StreamEndStop(), resultDisposition, true ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1668 } while( Catch::isTrue( false ) )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1669 #else
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1670 #define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, log ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1671 do { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1672 INTERNAL_CATCH_ACCEPT_INFO( "", macroName, resultDisposition ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1673 INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( messageType ) << log, resultDisposition, true ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1674 } while( Catch::isTrue( false ) )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1675 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1676
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1677 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1678 #define INTERNAL_CATCH_INFO( log, macroName ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1679 Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) = Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1680
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1681 ///////////////////////////////////////////////////////////////////////////////
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1682 #define INTERNAL_CHECK_THAT( arg, matcher, resultDisposition, macroName ) \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1683 do { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1684 INTERNAL_CATCH_ACCEPT_INFO( #arg " " #matcher, macroName, resultDisposition ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1685 try { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1686 INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::expressionResultBuilderFromMatcher( ::Catch::Matchers::matcher, arg, #matcher ) ), resultDisposition, false ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1687 } catch( Catch::TestFailureException& ) { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1688 throw; \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1689 } catch( ... ) { \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1690 INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException() ), \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1691 resultDisposition | Catch::ResultDisposition::ContinueOnFailure, false ); \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1692 } \
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1693 } while( Catch::isTrue( false ) )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1694
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1695 // #included from: internal/catch_section.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1696 #define TWOBLUECUBES_CATCH_SECTION_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1697
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1698 // #included from: catch_section_info.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1699 #define TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1700
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1701 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1702
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1703 struct SectionInfo {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1704 SectionInfo( std::string const& _name,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1705 std::string const& _description,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1706 SourceLineInfo const& _lineInfo )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1707 : name( _name ),
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1708 description( _description ),
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1709 lineInfo( _lineInfo )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1710 {}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1711
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1712 std::string name;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1713 std::string description;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1714 SourceLineInfo lineInfo;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1715 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1716
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1717 } // end namespace Catch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1718
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1719 // #included from: catch_totals.hpp
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1720 #define TWOBLUECUBES_CATCH_TOTALS_HPP_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1721
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1722 #include <cstddef>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1723
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1724 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1725
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1726 struct Counts {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1727 Counts() : passed( 0 ), failed( 0 ) {}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1728
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1729 Counts operator - ( Counts const& other ) const {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1730 Counts diff;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1731 diff.passed = passed - other.passed;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1732 diff.failed = failed - other.failed;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1733 return diff;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1734 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1735 Counts& operator += ( Counts const& other ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1736 passed += other.passed;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1737 failed += other.failed;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1738 return *this;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1739 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1740
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1741 std::size_t total() const {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1742 return passed + failed;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1743 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1744
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1745 std::size_t passed;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1746 std::size_t failed;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1747 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1748
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1749 struct Totals {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1750
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1751 Totals operator - ( Totals const& other ) const {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1752 Totals diff;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1753 diff.assertions = assertions - other.assertions;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1754 diff.testCases = testCases - other.testCases;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1755 return diff;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1756 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1757
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1758 Totals delta( Totals const& prevTotals ) const {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1759 Totals diff = *this - prevTotals;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1760 if( diff.assertions.failed > 0 )
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1761 ++diff.testCases.failed;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1762 else
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1763 ++diff.testCases.passed;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1764 return diff;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1765 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1766
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1767 Totals& operator += ( Totals const& other ) {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1768 assertions += other.assertions;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1769 testCases += other.testCases;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1770 return *this;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1771 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1772
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1773 Counts assertions;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1774 Counts testCases;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1775 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1776 }
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1777
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1778 // #included from: catch_timer.h
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1779 #define TWOBLUECUBES_CATCH_TIMER_H_INCLUDED
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1780
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1781 #ifdef CATCH_PLATFORM_WINDOWS
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1782 typedef unsigned long long uint64_t;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1783 #else
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1784 #include <stdint.h>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1785 #endif
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1786
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1787 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1788
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1789 class Timer {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1790 public:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1791 Timer() : m_ticks( 0 ) {}
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1792 void start();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1793 unsigned int getElapsedNanoseconds() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1794 unsigned int getElapsedMilliseconds() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1795 double getElapsedSeconds() const;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1796
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1797 private:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1798 uint64_t m_ticks;
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1799 };
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1800
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1801 } // namespace Catch
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1802
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1803 #include <string>
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1804
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1805 namespace Catch {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1806
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1807 class Section {
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1808 public:
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1809 Section( SourceLineInfo const& lineInfo,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1810 std::string const& name,
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1811 std::string const& description = "" );
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1812 ~Section();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1813
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1814 // This indicates whether the section should be executed or not
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1815 operator bool();
7c04a3e33dcc * Partial testing system
cemkalyoncu
parents:
diff changeset
1816