LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2006 Rutger E.W. van Beusekom. | 1 // Copyright 2006 Rutger E.W. van Beusekom. |
2 // Distributed under the Boost Software License, Version 1.0. (See | 2 // Distributed under the Boost Software License, Version 1.0. (See |
3 // accompanying file LICENSE_1_0.txt or copy at | 3 // accompanying file LICENSE_1_0.txt or copy at |
4 // http://www.boost.org/LICENSE_1_0.txt) | 4 // http://www.boost.org/LICENSE_1_0.txt) |
5 | 5 |
6 #ifndef __YAFFUT_H__ | 6 #ifndef __YAFFUT_H__ |
7 #define __YAFFUT_H__ | 7 #define __YAFFUT_H__ |
8 | 8 |
9 #include "config.hh" | 9 #include "config.hh" |
10 #if HAVE_CXA_DEMANGLE | 10 #if HAVE_CXA_DEMANGLE |
11 #include <cxxabi.h> | 11 #include <cxxabi.h> |
12 #else | 12 #else |
13 #include <typeinfo> | 13 #include <typeinfo> |
14 #endif | 14 #endif |
15 | 15 |
16 #include <cmath> | 16 #include <cmath> |
17 #include <cstring> | 17 #include <cstring> |
18 #include <iostream> | 18 #include <iostream> |
19 #include <limits> | 19 #include <limits> |
20 #include <map> | 20 #include <map> |
21 #include <memory> | 21 #include <memory> |
22 #include <sstream> | 22 #include <sstream> |
23 #include <stdexcept> | 23 #include <stdexcept> |
| 24 #include <unistd.h> |
24 | 25 |
25 #define YAFFUT_STRINGIZE(x) YAFFUT_STRINGIZE_(x) | 26 #define YAFFUT_STRINGIZE(x) YAFFUT_STRINGIZE_(x) |
26 #define YAFFUT_STRINGIZE_(x) #x | 27 #define YAFFUT_STRINGIZE_(x) #x |
27 | 28 |
28 #define __YAFFUT_AT__ __FILE__ ":" YAFFUT_STRINGIZE(__LINE__)": " | 29 #define __YAFFUT_AT__ __FILE__ ":" YAFFUT_STRINGIZE(__LINE__)": " |
29 #ifndef __AT__ | 30 #ifndef __AT__ |
30 #define __AT__ __YAFFUT_AT__ | 31 #define __AT__ __YAFFUT_AT__ |
31 #endif | 32 #endif |
32 | 33 |
33 #define YAFFUT_EQUAL(e,a) \ | 34 #define YAFFUT_EQUAL(e,a) \ |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 return new Case; | 271 return new Case; |
271 } | 272 } |
272 }; | 273 }; |
273 | 274 |
274 template <typename Suite, typename Case = void> | 275 template <typename Suite, typename Case = void> |
275 struct Test: public ITest, public virtual Suite | 276 struct Test: public ITest, public virtual Suite |
276 { | 277 { |
277 static Registrator<Suite, Case> s_Registrator; | 278 static Registrator<Suite, Case> s_Registrator; |
278 Test (): Suite () | 279 Test (): Suite () |
279 { | 280 { |
280 Registrator<Suite, Case>* r = &s_Registrator; | 281 Registrator<Suite, Case> *r = &s_Registrator; |
281 (void)r; | 282 (void)r; |
282 } | 283 } |
283 template <typename E, typename T> | 284 template <typename E, typename T> |
284 void assert_throw (void (T::*mf) (), const char *at) | 285 void assert_throw (void (T::*mf) (), const char *at) |
285 { | 286 { |
286 try | 287 try |
287 { | 288 { |
288 (dynamic_cast<T *> (this)->*mf) (); | 289 (dynamic_cast<T *> (this)->*mf) (); |
289 throw yaffut::failure (at, "statement failed to throw"); | 290 throw yaffut::failure (at, "statement failed to throw"); |
290 } | 291 } |
291 catch (const E &) {} | 292 catch (const E &) {} |
292 } | 293 } |
293 }; | 294 }; |
294 | 295 |
295 template <typename Suite, typename Case> | 296 template <typename Suite, typename Case> |
296 Registrator<Suite, Case> Test<Suite, Case>::s_Registrator; | 297 Registrator<Suite, Case> Test<Suite, Case>::s_Registrator; |
297 | 298 |
298 template <typename Case> | 299 template <typename Case> |
299 struct Test<Case, void>: public ITest | 300 struct Test<Case, void>: public ITest |
300 { | 301 { |
301 static Registrator<Case, void> s_Registrator; | 302 static Registrator<Case, void> s_Registrator; |
302 Test () | 303 Test () |
303 { | 304 { |
304 Registrator<Case, void>* r = &s_Registrator; | 305 Registrator<Case, void> *r = &s_Registrator; |
305 (void)r; | 306 (void)r; |
306 } | 307 } |
307 template <typename E, typename T> | 308 template <typename E, typename T> |
308 void assert_throw (void (T::*mf) (), const char *at) | 309 void assert_throw (void (T::*mf) (), const char *at) |
309 { | 310 { |
310 try | 311 try |
311 { | 312 { |
312 (dynamic_cast<T *> (this)->*mf) (); | 313 (dynamic_cast<T *> (this)->*mf) (); |
313 throw yaffut::failure (at, "statement failed to throw"); | 314 throw yaffut::failure (at, "statement failed to throw"); |
314 } | 315 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 { | 403 { |
403 std::cout << "pid(" << getpid () << ")" << std::endl; | 404 std::cout << "pid(" << getpid () << ")" << std::endl; |
404 return yaffut::Factory::Instance ().Main (argc, argv); | 405 return yaffut::Factory::Instance ().Main (argc, argv); |
405 }; | 406 }; |
406 | 407 |
407 #endif /* YAFFUT_MAIN */ | 408 #endif /* YAFFUT_MAIN */ |
408 | 409 |
409 #define yaffut_main(argc, argv) yaffut::Factory::Instance().Main (argc, argv) | 410 #define yaffut_main(argc, argv) yaffut::Factory::Instance().Main (argc, argv) |
410 | 411 |
411 #endif | 412 #endif |
LEFT | RIGHT |