iutest  1.17.1.0
iutest_internal.hpp
[詳解]
1 //======================================================================
2 //-----------------------------------------------------------------------
13 //-----------------------------------------------------------------------
14 //======================================================================
15 #ifndef INCG_IRIS_IUTEST_INTERNAL_HPP_A5BD9FBB_B57A_4C1D_B205_0ADB7798DBF9_
16 #define INCG_IRIS_IUTEST_INTERNAL_HPP_A5BD9FBB_B57A_4C1D_B205_0ADB7798DBF9_
17 
18 //======================================================================
19 // include
20 #include "../iutest_pred.hpp"
21 #include "../iutest_package.hpp"
22 
23 #if defined(__clang_analyzer__)
24 # include <assert.h>
25 #endif
26 
27 //======================================================================
28 // define
33 #define IUTEST_TEST_CLASS_NAME_(testcase_, testname_) IIUT_TEST_CLASS_NAME_I(IIUT_TO_VARNAME_(testcase_), IIUT_TO_VARNAME_(testname_))
34 #define IIUT_TEST_CLASS_NAME_I(testcase_, testname_) IIUT_TEST_CLASS_NAME_I_(testcase_, testname_)
35 #define IIUT_TEST_CLASS_NAME_I_(testcase_, testname_) iu_##testcase_##_x_iutest_x_##testname_##_Test
36 
37 #define IUTEST_TEST_INSTANCE_NAME_(testcase_, testname_) IIUT_TEST_INSTANCE_NAME_I(IIUT_TO_VARNAME_(testcase_), IIUT_TO_VARNAME_(testname_))
38 #define IIUT_TEST_INSTANCE_NAME_I(testcase_, testname_) IIUT_TEST_INSTANCE_NAME_I_(testcase_, testname_)
39 #define IIUT_TEST_INSTANCE_NAME_I_(testcase_, testname_) s_##testcase_##_x_iutest_x_##testname_##_Instance
40 
41 #if IUTEST_HAS_TESTNAME_ALIAS
42 
43 #define IIUT_TO_VARNAME_(name_) IIUT_TO_VARNAME_I( (IIUT_ALIAS_TESTNAME_PP_##name_, name_, dummy_) )
44 #define IIUT_TO_VARNAME_I(tuple_) IUTEST_PP_EXPAND( IIUT_TO_VARNAME_I_ tuple_ )
45 #define IIUT_TO_VARNAME_I_(dummy, name_, ...) name_
46 
47 #define IIUT_TO_NAME_(name_) IIUT_TO_NAME_I( (IIUT_ALIAS_TESTNAME_PP_##name_, name_, name_, dummy_) )
48 #define IIUT_TO_NAME_I(tuple_) IUTEST_PP_EXPAND( IIUT_TO_NAME_I_ tuple_ )
49 #define IIUT_TO_NAME_I_(dummy, dummy_2, name_, ...) name_
50 
51 #define IIUT_TO_NAME_STR_(name_) IUTEST_PP_TOSTRING( IIUT_TO_NAME_(name_) )
52 
53 #define IIUT_ALIAS_TESTNAME_PP_UNPAREN_(...) __VA_ARGS__
54 
55 #if defined(_MSC_VER) && !defined(__clang__)
56 # define IUTEST_ALIAS_TESTNAME_(name_) name_
57 # define IUTEST_ALIAS_TESTNAME_F_(name_, var_) UNPAREN_(dummy, var_, name_)
58 #else
59 # define IUTEST_ALIAS_TESTNAME_(name_) UNPAREN_(dummy, IUTEST_PP_CAT(iutest_japanese_var, __LINE__), name_)
60 # define IUTEST_ALIAS_TESTNAME_F_(name_, var_) UNPAREN_(dummy, var_, name_)
61 #endif
62 
63 #else
64 
65 #define IIUT_TO_VARNAME_(name_) name_
66 #define IIUT_TO_NAME_(name_) name_
67 #define IIUT_TO_NAME_STR_(name_) #name_
68 
69 #endif
70 
71 #if IUTEST_HAS_IF_EXISTS
72 # define IIUT_CHECK_TESTFIXTURE_I(testfixture_) \
73  IUTEST_IF_EXISTS(testfixture_, IUTEST_IF_EXISTS(testfixture_::SetUp, \
74  IUTEST_STATIC_ASSERT_MSG( \
75  (!::iutest_type_traits::is_base_of< ::iutest::Test, testfixture_ >::value) \
76  , #testfixture_ " is fixture class, mistake the IUTEST_F?"); \
77  ) )
78 #elif !defined(IUTEST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING)
79 # define IIUT_CHECK_TESTFIXTURE_I(testfixture_) \
80  IUTEST_STATIC_ASSERT_MSG( \
81  (! ::iutest::detail::is_useful_testfixture< void (int (testfixture_)) >::value) \
82  , #testfixture_ " is fixture class, mistake the IUTEST_F?");
83 #else
84 # define IIUT_CHECK_TESTFIXTURE_I(testfixture_)
85 #endif
86 #define IIUT_CHECK_TESTFIXTURE_(testfixture_) IIUT_CHECK_TESTFIXTURE_I(testfixture_)
87 #define IIUT_CHECK_TESTFIXTURE(testfixture_) IIUT_CHECK_TESTFIXTURE_(IIUT_TO_VARNAME_(testfixture_))
88 
89 #if !defined(IUTEST_TEST_STRICT_)
90 #if IUTEST_CHECK_STRICT
91 # define IUTEST_TEST_STRICT_(testcase_, testname_, parent_class_, type_id_) \
92  IIUT_CHECK_TESTFIXTURE(testcase_) \
93  IUTEST_TEST_(testcase_, testname_, parent_class_, type_id_)
94 #else
95 # define IUTEST_TEST_STRICT_ IUTEST_TEST_
96 #endif
97 #endif
98 
99 #define IIUT_TEST_F_(macro, testfixture_, testname_) \
100  macro(testfixture_, testname_, IIUT_TO_VARNAME_(testfixture_) \
101  , ::iutest::internal::GetTypeId< IIUT_TO_VARNAME_(testfixture_) >())
102 
103 #if IUTEST_HAS_TESTFIXTURE_ALIAS_BY_TUPLE
104 
105 #define IIUT_TEST_F_A_(macro, testfixture_, testname_) \
106  IIUT_TEST_F_( macro, IUTEST_PP_IF( IUTEST_PP_IS_BEGIN_PARENS(testfixture_) \
107  , IUTEST_ALIAS_TESTNAME_F_, IUTEST_PP_EMPTY() ) testfixture_, testname_)
108 
109 #define IUTEST_TEST_F_(testfixture_, testname_) \
110  IIUT_TEST_F_A_(IUTEST_TEST_, testfixture_, testname_)
111 
112 #if IUTEST_HAS_IGNORE_TEST
113 
114 #define IUTEST_TEST_F_IGNORE_(testfixture_, testname_) \
115  IIUT_TEST_F_A_( IUTEST_TEST_IGNORE_, testfixture_, testname_)
116 
117 #endif
118 
119 #else
120 
121 #define IUTEST_TEST_F_(testfixture_, testname_) \
122  IIUT_TEST_F_(IUTEST_TEST_, testfixture_, testname_)
123 
124 #if IUTEST_HAS_IGNORE_TEST
125 
126 #define IUTEST_TEST_F_IGNORE_(testfixture_, testname_) \
127  IIUT_TEST_F_( IUTEST_TEST_IGNORE_, testfixture_, testname_)
128 
129 #endif
130 
131 #endif
132 
141 #define IUTEST_TEST_(testcase_, testname_, parent_class_, type_id_) \
142  class IUTEST_TEST_CLASS_NAME_(testcase_, testname_) : public parent_class_ { \
143  IUTEST_PP_DISALLOW_COPY_AND_ASSIGN(IUTEST_TEST_CLASS_NAME_(testcase_, testname_)); \
144  public: IUTEST_TEST_CLASS_NAME_(testcase_, testname_)() {} \
145  protected: virtual void Body() IUTEST_CXX_OVERRIDE; \
146  }; \
147  ::iutest::detail::TestInstance<IUTEST_TEST_CLASS_NAME_(testcase_, testname_)> \
148  IUTEST_TEST_INSTANCE_NAME_(testcase_, testname_)( \
149  IUTEST_CONCAT_PACKAGE_(IIUT_TO_NAME_(testcase_)), IIUT_TO_NAME_STR_(testname_) \
150  , type_id_, parent_class_::SetUpTestCase, parent_class_::TearDownTestCase); \
151  void IUTEST_TEST_CLASS_NAME_(testcase_, testname_)::Body()
152 
153 #if IUTEST_HAS_IGNORE_TEST
154 
160 #define IUTEST_TEST_IGNORE_(testcase_, testname_, parent_class_, type_id_) \
161  class IUTEST_TEST_CLASS_NAME_(testcase_, testname_) : public parent_class_ { \
162  IUTEST_PP_DISALLOW_COPY_AND_ASSIGN( IUTEST_TEST_CLASS_NAME_(testcase_, testname_) ); \
163  public: IUTEST_TEST_CLASS_NAME_(testcase_, testname_)() {} \
164  protected: virtual void Body() IUTEST_CXX_OVERRIDE { IUTEST_SKIP() << "ignored test..."; } \
165  template<typename T>void Body(); \
166  }; \
167  ::iutest::detail::TestInstance<IUTEST_TEST_CLASS_NAME_(testcase_, testname_)> \
168  IUTEST_TEST_INSTANCE_NAME_(testcase_, testname_)( \
169  IUTEST_CONCAT_PACKAGE_(IIUT_TO_NAME_(testcase_)), IIUT_TO_NAME_STR_(testname_) \
170  , type_id_, parent_class_::SetUpTestCase, parent_class_::TearDownTestCase); \
171  template<typename T>void IUTEST_TEST_CLASS_NAME_(testcase_, testname_ )::Body()
172 
173 #endif
174 
175 #if !defined(IUTEST_NO_VARIADIC_MACROS)
176 
181 #define IUTEST_PMZ_TEST_CLASS_NAME_(testcase_, testname_) IIUT_PMZ_TEST_CLASS_NAME_I(IIUT_TO_VARNAME_(testcase_), IIUT_TO_VARNAME_(testname_))
182 #define IIUT_PMZ_TEST_CLASS_NAME_I(testcase_, testname_) IIUT_PMZ_TEST_CLASS_NAME_I_(testcase_, testname_)
183 #define IIUT_PMZ_TEST_CLASS_NAME_I_(testcase_, testname_) IUTEST_PP_CAT( IUTEST_PP_CAT(iu_##testcase_##_x_Test_, testname_), __LINE__)
184 
192 #define IIUT_TEST_PMZ_(testcase_, testname_, method_, parent_class_, type_id_, ...) \
193  class IUTEST_TEST_CLASS_NAME_(testcase_, testname_); \
194  class IUTEST_PMZ_TEST_CLASS_NAME_(testcase_, testname_) : public parent_class_ { \
195  IUTEST_PP_DISALLOW_COPY_AND_ASSIGN(IUTEST_PMZ_TEST_CLASS_NAME_(testcase_, testname_)); \
196  public: IUTEST_PMZ_TEST_CLASS_NAME_(testcase_, testname_)() {} \
197  static ::std::string MakeTestName() { return ::iutest::detail::MakeIndexTestName( \
198  IIUT_TO_NAME_STR_(testname_), ::iutest::detail::GetTypeUniqueCounter< \
199  IUTEST_TEST_CLASS_NAME_(testcase_, testname_)>()); } \
200  protected: virtual void Body() IUTEST_CXX_OVERRIDE { method_(__VA_ARGS__); } \
201  }; \
202  ::iutest::detail::TestInstance<IUTEST_PMZ_TEST_CLASS_NAME_(testcase_, testname_)> \
203  IUTEST_PP_CAT( IUTEST_TEST_INSTANCE_NAME_(testcase_, testname_), __LINE__)( \
204  IUTEST_CONCAT_PACKAGE_(IIUT_TO_NAME_(testcase_)) \
205  , IUTEST_PMZ_TEST_CLASS_NAME_(testcase_, testname_)::MakeTestName().c_str() \
206  , #__VA_ARGS__, type_id_, parent_class_::SetUpTestCase, parent_class_::TearDownTestCase)
207 
208 #endif
209 
214 #define IUTEST_CLASS_INITIALIZE(methodName) static void SetUpTestCase() { methodName(); } static void methodName()
215 #define IUTEST_CLASS_CLEANUP(methodName) static void TearDownTestCase() { methodName(); } static void methodName()
216 
217 #define IUTEST_METHOD_INITIALIZE(methodName) virtual void SetUp() IUTEST_CXX_OVERRIDE { methodName(); } void methodName()
218 #define IUTEST_METHOD_CLEANUP(methodName) virtual void TearDown() IUTEST_CXX_OVERRIDE { methodName(); } void methodName()
219 
227 #define IUTEST_MESSAGE_AT(file_, line_, msg_, result_type_) \
228  ::iutest::AssertionHelper(file_, line_, msg_, result_type_) = ::iutest::AssertionHelper::Fixed()
229 #define IUTEST_MESSAGE(msg_, result_type_) \
230  IUTEST_MESSAGE_AT(__FILE__, __LINE__, msg_, result_type_)
231 
236 #define IUTEST_ASSERT_FAILURE(msg) IUTEST_ASSERT_FAILURE_AT(msg, __FILE__, __LINE__)
237 
238 #if !defined(IUTEST_NO_VOID_RETURNS)
239 # define IUTEST_ASSERT_FAILURE_AT(msg, file, line) return IUTEST_MESSAGE_AT(file, line, msg, ::iutest::TestPartResult::kFatalFailure)
240 #else
241 # define IUTEST_ASSERT_FAILURE_AT(msg, file, line) IUTEST_MESSAGE_AT(file, line, msg, ::iutest::TestPartResult::kFatalFailure)
242 #endif
243 
248 #define IUTEST_EXPECT_FAILURE(msg) IUTEST_EXPECT_FAILURE_AT(msg, __FILE__, __LINE__)
249 
250 #define IUTEST_EXPECT_FAILURE_AT(msg, file, line) IUTEST_MESSAGE_AT(file, line, msg, ::iutest::TestPartResult::kNonFatalFailure)
251 
256 #define IUTEST_INFORM_FAILURE(msg) IUTEST_INFORM_FAILURE_AT(msg, __FILE__, __LINE__)
257 
258 #define IUTEST_INFORM_FAILURE_AT(msg, file, line) IUTEST_MESSAGE_AT(file, line, msg, ::iutest::TestPartResult::kWarning)
259 
264 #define IUTEST_ASSUME_FAILURE(msg) IUTEST_ASSUME_FAILURE_AT(msg, __FILE__, __LINE__)
265 
266 #if !defined(IUTEST_NO_VOID_RETURNS)
267 # define IUTEST_ASSUME_FAILURE_AT(msg, file, line) \
268  return IUTEST_MESSAGE_AT(file, line, msg, ::iutest::TestPartResult::kAssumeFailure)
269 #else
270 # define IUTEST_ASSUME_FAILURE_AT(msg, file, line) \
271  IUTEST_MESSAGE_AT(file, line, msg, ::iutest::TestPartResult::kAssumeFailure)
272 #endif
273 
278 #define IUTEST_SKIP_MESSAGE(msg) IUTEST_SKIP_MESSAGE_AT(msg, __FILE__, __LINE__)
279 
280 #if !defined(IUTEST_NO_VOID_RETURNS)
281 # define IUTEST_SKIP_MESSAGE_AT(msg, file, line) \
282  return IUTEST_MESSAGE_AT(file, line, msg, ::iutest::TestPartResult::kSkip)
283 #else
284 # define IUTEST_SKIP_MESSAGE_AT(msg, file, line) \
285  IUTEST_MESSAGE_AT(file, line, msg, ::iutest::TestPartResult::kSkip)
286 #endif
287 
288 #ifndef IUTEST_MAKE_ASSERTIONRESULT_
289 # define IUTEST_MAKE_ASSERTIONRESULT_(ar) ar
290 #endif
291 
296 #define IUTEST_TEST_ASSERT_(expression, on_failure) \
297  IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \
298  if( const ::iutest::AssertionResult iutest_ar = IUTEST_MAKE_ASSERTIONRESULT_(expression) ) \
299  ; \
300  else \
301  on_failure(iutest_ar.message())
302 
303 #if IUTEST_HAS_EXCEPTIONS
304 
305 #if IUTEST_HAS_CATCH_SEH_EXCEPTION_ASSERTION
306 
307 #define IIUT_SEH_THROUGH(statement) ::iutest::detail::seh_passthrough([&](){ (void)(statement); })
308 
309 #else
310 
311 #define IIUT_SEH_THROUGH(statement) (void)(statement)
312 
313 #endif
314 
319 #define IUTEST_TEST_THROW_(statement, expected_exception, on_failure) \
320  IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \
321  if( const char* msg = "" ) { \
322  try { \
323  IUTEST_SUPPRESS_UNREACHABLE_CODE_WARNING(IIUT_SEH_THROUGH(statement)); \
324  msg = "\nExpected: " #statement " throws an exception of type " \
325  #expected_exception ".\n Actual: it throws nothing."; \
326  goto IUTEST_PP_CAT(iutest_label_throw, __LINE__); \
327  } catch( expected_exception const& ) { \
328  } catch( ... ) { \
329  msg = "\nExpected: " #statement " throws an exception of type " \
330  #expected_exception ".\n Actual: it throws a different type."; \
331  goto IUTEST_PP_CAT(iutest_label_throw, __LINE__); \
332  } \
333  } else \
334  IUTEST_PP_CAT(iutest_label_throw, __LINE__): \
335  on_failure(msg)
336 
341 #define IUTEST_TEST_THROW_VALUE_(statement, expected_exception, expected_exception_value, on_failure, pred_formatter) \
342  IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \
343  if( ::iutest::AssertionResult iutest_ar = ::iutest::AssertionSuccess() ) { \
344  try { \
345  IUTEST_SUPPRESS_UNREACHABLE_CODE_WARNING(IIUT_SEH_THROUGH(statement)); \
346  iutest_ar << "\nExpected: " #statement " throws an exception of type " \
347  #expected_exception ".\n Actual: it throws nothing."; \
348  goto IUTEST_PP_CAT(iutest_label_throw_value, __LINE__); \
349  } catch( expected_exception const& e) { \
350  if( const ::iutest::AssertionResult ar \
351  = pred_formatter("e", #expected_exception_value, e, expected_exception_value) ) { \
352  } else { \
353  iutest_ar << "\nExpected: " #statement " throws an exception of value\n" << ar.message(); \
354  goto IUTEST_PP_CAT(iutest_label_throw_value, __LINE__); \
355  } \
356  } catch( ... ) { \
357  iutest_ar << "\nExpected: " #statement " throws an exception of type " \
358  #expected_exception ".\n Actual: it throws a different type."; \
359  goto IUTEST_PP_CAT(iutest_label_throw_value, __LINE__); \
360  } \
361  } else \
362  IUTEST_PP_CAT(iutest_label_throw_value, __LINE__): \
363  on_failure(iutest_ar.message())
364 
365 #define IUTEST_TEST_THROW_VALUE_EQ_(statement, expected_exception, expected_exception_value, on_failure) \
366  IUTEST_TEST_THROW_VALUE_(statement, expected_exception, expected_exception_value, on_failure \
367  , ::iutest::internal::backward::EqHelper<IUTEST_IS_NULLLITERAL(expected_exception_value)>::Compare)
368 #define IUTEST_TEST_THROW_VALUE_NE_(statement, expected_exception, expected_exception_value, on_failure) \
369  IUTEST_TEST_THROW_VALUE_(statement, expected_exception, expected_exception_value, on_failure \
370  , ::iutest::internal::backward::NeHelper<IUTEST_IS_NULLLITERAL(expected_exception_value)>::Compare)
371 #define IUTEST_TEST_THROW_VALUE_STREQ_(statement, expected_exception, expected_exception_value, on_failure) \
372  IUTEST_TEST_THROW_VALUE_(statement, expected_exception, expected_exception_value, on_failure \
373  , ::iutest::internal::CmpHelperSTREQ)
374 #define IUTEST_TEST_THROW_VALUE_STRCASEEQ_(statement, expected_exception, expected_exception_value, on_failure) \
375  IUTEST_TEST_THROW_VALUE_(statement, expected_exception, expected_exception_value, on_failure \
376  , ::iutest::internal::CmpHelperSTRCASEEQ)
377 
382 #define IUTEST_TEST_ANY_THROW_(statement, on_failure) \
383  IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \
384  if( ::iutest::detail::AlwaysTrue() ) { \
385  try { \
386  IIUT_SEH_THROUGH(statement); \
387  goto IUTEST_PP_CAT(iutest_label_anythrow, __LINE__); \
388  } catch( ... ) { \
389  } \
390  } else \
391  IUTEST_PP_CAT(iutest_label_anythrow, __LINE__): \
392  on_failure("\nExpected: " #statement " throws an exception.\n Actual: it doesn's throws.")
393 
398 #define IUTEST_TEST_NO_THROW_(statement, on_failure) \
399  IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \
400  if( ::iutest::AssertionResult iutest_ar = ::iutest::AssertionSuccess() ) { \
401  try { \
402  IIUT_SEH_THROUGH(statement); \
403  } catch( const ::std::exception& e ) { \
404  iutest_ar << "\nExpected: " #statement " doesn't throw an exception.\n Actual: it throws. what is \"" \
405  << e.what() << "\""; \
406  goto IUTEST_PP_CAT(iutest_label_nothrow, __LINE__); \
407  } catch( const char *e ) { \
408  iutest_ar << "\nExpected: " #statement " doesn't throw an exception.\n Actual: it throws. \"" \
409  << e << "\""; \
410  goto IUTEST_PP_CAT(iutest_label_nothrow, __LINE__); \
411  } catch( ... ) { \
412  iutest_ar << "\nExpected: " #statement " doesn't throw an exception.\n Actual: it throws."; \
413  goto IUTEST_PP_CAT(iutest_label_nothrow, __LINE__); \
414  } \
415  } else \
416  IUTEST_PP_CAT(iutest_label_nothrow, __LINE__): \
417  on_failure(iutest_ar.message())
418 
419 #endif
420 
421 #define IUTEST_TEST_BOOLEAN_(expression, text, actual, expected, on_failure) \
422  IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \
423  if( const ::iutest::AssertionResult iutest_ar = ::iutest::AssertionResult::Is(expression) ) \
424  ; \
425  else \
426  on_failure(::iutest::internal::GetBooleanAssertionFailureMessage( \
427  iutest_ar, text, #actual, #expected).c_str() )
428 
433 #define IUTEST_ASSERT_EXIT(cond) do { if( !(cond) ) { \
434  IUTEST_MESSAGE(#cond, ::iutest::TestPartResult::kFatalFailure); \
435  exit(1); \
436  } } while(::iutest::detail::AlwaysFalse())
437 
442 #define IIUT_SUCCEED() IUTEST_MESSAGE("Succeeded.\n", ::iutest::TestPartResult::kSuccess)
443 
447 #define IIUT_FAIL() IUTEST_ASSERT_FAILURE("Failed.\n")
448 #define IIUT_ADD_FAILURE() IUTEST_EXPECT_FAILURE("Failed.\n")
449 #define IIUT_ADD_FAILURE_AT(file_, line_) IUTEST_EXPECT_FAILURE_AT("Failed.\n", file_, line_)
450 
455 #define IIUT_SCOPED_MESSAGE(msg_) \
456  const ::iutest::AssertionHelper::ScopedMessage IUTEST_PP_CAT(scoped_message_, IUTEST_PP_COUNTER) = \
457  ::iutest::detail::iuCodeMessage(__FILE__, __LINE__, ::iutest::Message() << (msg_))
458 
463 #if IUTEST_HAS_ANALYSIS_ASSUME
464 # define IUTEST_ANALYSIS_ASSUME_DELEGATE IUTEST_ANALYSIS_ASSUME
465 #elif defined(__clang_analyzer__)
466 # define IUTEST_ANALYSIS_ASSUME_DELEGATE assert
467 #endif
468 
469 #if defined(IUTEST_ANALYSIS_ASSUME_DELEGATE)
470 #define IUTEST_THROUGH_ANALYSIS_ASSUME_(expr, todo) \
471  IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \
472  if( bool b = true ) { \
473  IUTEST_UNUSED_VAR(b); \
474  IUTEST_ANALYSIS_ASSUME_DELEGATE(expr); \
475  goto IUTEST_PP_CAT(iutest_label_analysis_assume, __LINE__); \
476  } else \
477  IUTEST_PP_CAT(iutest_label_analysis_assume, __LINE__): \
478  todo
479 
480 #else
481 
482 #define IUTEST_THROUGH_ANALYSIS_ASSUME_(expr, todo) todo
483 
484 #endif
485 
491 #define IUTEST_TEST_EQ(expected, actual, on_failure) \
492  IUTEST_PRED_FORMAT2_( ::iutest::internal::backward::EqHelper<IUTEST_IS_NULLLITERAL(expected)>::Compare \
493  , expected, actual, on_failure )
494 
495 #define IUTEST_TEST_ALMOST_EQ(expected, actual, on_failure) \
496  IUTEST_PRED_FORMAT2_( ::iutest::internal::backward::AlmostEqHelper<IUTEST_IS_NULLLITERAL(expected)>::Compare \
497  , expected, actual, on_failure )
498 
499 #define IUTEST_TEST_NE(v1, v2, on_failure) \
500  IUTEST_PRED_FORMAT2_( ::iutest::internal::backward::NeHelper<IUTEST_IS_NULLLITERAL(v1)>::Compare \
501  , v1, v2, on_failure )
502 
503 #define IUTEST_TEST_LE(v1, v2, on_failure) \
504  IUTEST_PRED_FORMAT2_( ::iutest::internal::CmpHelperLE \
505  , v1, v2, on_failure )
506 
507 #define IUTEST_TEST_LT(v1, v2, on_failure) \
508  IUTEST_PRED_FORMAT2_( ::iutest::internal::CmpHelperLT \
509  , v1, v2, on_failure )
510 
511 #define IUTEST_TEST_GE(v1, v2, on_failure) \
512  IUTEST_PRED_FORMAT2_( ::iutest::internal::CmpHelperGE \
513  , v1, v2, on_failure )
514 
515 #define IUTEST_TEST_GT(v1, v2, on_failure) \
516  IUTEST_PRED_FORMAT2_( ::iutest::internal::CmpHelperGT \
517  , v1, v2, on_failure )
518 
519 #define IUTEST_TEST_TRUE(expr, text, on_failure) \
520  IUTEST_TEST_BOOLEAN_( expr, text, false, true, on_failure)
521 
522 #define IUTEST_TEST_FALSE(expr, text, on_failure) \
523  IUTEST_TEST_BOOLEAN_( !(expr), text, true, false, on_failure)
524 
525 #define IUTEST_TEST_FLOAT_EQ(expected, actual, on_failure) \
526  IUTEST_PRED_FORMAT2_( ::iutest::internal::CmpHelperFloatingPointEQ<float> \
527  , expected, actual, on_failure )
528 
529 #define IUTEST_TEST_DOUBLE_EQ(expected, actual, on_failure) \
530  IUTEST_PRED_FORMAT2_( ::iutest::internal::CmpHelperFloatingPointEQ<double> \
531  , expected, actual, on_failure )
532 
533 #if IUTEST_HAS_LONG_DOUBLE
534 
535 #define IUTEST_TEST_LONG_DOUBLE_EQ(expected, actual, on_failure) \
536  IUTEST_PRED_FORMAT2_( ::iutest::internal::CmpHelperFloatingPointEQ<long double> \
537  , expected, actual, on_failure )
538 
539 #endif
540 
541 #define IUTEST_TEST_NEAR(v1, v2, abs_v, on_failure) \
542  IUTEST_PRED_FORMAT3_( ::iutest::internal::CmpHelperNear \
543  , v1, v2, abs_v, on_failure )
544 
545 #define IUTEST_TEST_STREQ(expected, actual, on_failure) \
546  IUTEST_PRED_FORMAT2_( ::iutest::internal::CmpHelperSTREQ \
547  , expected, actual, on_failure )
548 
549 #define IUTEST_TEST_STRNE(v1, v2, on_failure) \
550  IUTEST_PRED_FORMAT2_( ::iutest::internal::CmpHelperSTRNE \
551  , v1, v2, on_failure )
552 
553 #define IUTEST_TEST_STRCASEEQ(expected, actual, on_failure) \
554  IUTEST_PRED_FORMAT2_( ::iutest::internal::CmpHelperSTRCASEEQ \
555  , expected, actual, on_failure )
556 
557 #define IUTEST_TEST_STRCASENE(v1, v2, on_failure) \
558  IUTEST_PRED_FORMAT2_( ::iutest::internal::CmpHelperSTRCASENE \
559  , v1, v2, on_failure )
560 
561 #if defined(IUTEST_OS_WINDOWS)
562 
563 #define IUTEST_TEST_HRESULT_SUCCEEDED(hr, on_failure) \
564  IUTEST_PRED_FORMAT1_( ::iutest::internal::IsHRESULTSuccess \
565  , hr, on_failure )
566 
567 #define IUTEST_TEST_HRESULT_FAILED(hr, on_failure) \
568  IUTEST_PRED_FORMAT1_( ::iutest::internal::IsHRESULTFailure \
569  , hr, on_failure )
570 
571 #endif
572 
573 #define IUTEST_TEST_SAME(v1, v2, on_failure) \
574  IUTEST_PRED_FORMAT2_( ::iutest::internal::CmpHelperSame \
575  , v1, v2, on_failure )
576 
577 #define IUTEST_TEST_NULL(v, on_failure) \
578  IUTEST_THROUGH_ANALYSIS_ASSUME_(v==IUTEST_NULLPTR \
579  , IUTEST_PRED_FORMAT1_( ::iutest::internal::NullHelper<IUTEST_IS_NULLLITERAL(v)>::CompareEq \
580  , v, on_failure ))
581 
582 #define IUTEST_TEST_NOTNULL(v, on_failure) \
583  IUTEST_THROUGH_ANALYSIS_ASSUME_(v!=IUTEST_NULLPTR \
584  , IUTEST_PRED_FORMAT1_( ::iutest::internal::NullHelper<IUTEST_IS_NULLLITERAL(v)>::CompareNe \
585  , v, on_failure ))
586 
587 #define IUTEST_TEST_NO_FAILURE_(statement, on_failure) \
588  IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \
589  if( ::iutest::detail::AlwaysTrue() ) { \
590  ::iutest::detail::NewTestPartResultCheckHelper::Counter< \
591  ::iutest::detail::NewTestPartResultCheckHelper::CondGt< \
592  ::iutest::TestPartResult::kSuccess> > iutest_failure_checker; \
593  IUTEST_SUPPRESS_UNREACHABLE_CODE_WARNING( { (void)0; statement; } ) \
594  if( iutest_failure_checker.count() > 0 ) { \
595  goto IUTEST_PP_CAT(iutest_label_test_no_failure_, __LINE__); \
596  } \
597  } else \
598  IUTEST_PP_CAT(iutest_label_test_no_failure_, __LINE__): \
599  on_failure("\nExpected: " #statement " doesn't generate new failure.\n Actual: it does.")
600 
601 #define IUTEST_TEST_NO_FATAL_FAILURE_(statement, on_failure) \
602  IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \
603  if( ::iutest::detail::AlwaysTrue() ) { \
604  ::iutest::detail::NewTestPartResultCheckHelper::Counter< \
605  ::iutest::detail::NewTestPartResultCheckHelper::CondEq< \
606  ::iutest::TestPartResult::kFatalFailure> > iutest_failure_checker; \
607  IUTEST_SUPPRESS_UNREACHABLE_CODE_WARNING( { (void)0; statement; } ) \
608  if( iutest_failure_checker.count() > 0 ) { \
609  goto IUTEST_PP_CAT(iutest_label_test_no_fatalfailure_, __LINE__); \
610  } \
611  } else \
612  IUTEST_PP_CAT(iutest_label_test_no_fatalfailure_, __LINE__): \
613  on_failure("\nExpected: " #statement " doesn't generate new fatal failure.\n Actual: it does.")
614 
615 #define IUTEST_TEST_SKIP() \
616  IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \
617  if( ::iutest::detail::AlwaysTrue() ) \
618  IUTEST_SKIP_MESSAGE( ::iutest::UnitTest::SkipTest() ? "Skipped. " : "Skipped. but already failed. " )
619 
627 #if defined(_MSC_VER) && !defined(__clang__)
628 # define IUTEST_TEST_COMPILEERROR(e) \
629  IUTEST_PRAGMA_MESSAGE(__FILE__ "(" IUTEST_PP_TOSTRING(__LINE__) "): note : " "IUTEST_TEST_COMPILEERROR( " #e " )")
630 #else
631 # define IUTEST_TEST_COMPILEERROR(e) \
632  IUTEST_PRAGMA_MESSAGE("IUTEST_TEST_COMPILEERROR( " #e " )")
633 #endif
634 
639 #if IUTEST_HAS_STATIC_ASSERT
640 # define IUTEST_TEST_STATICASSERT(e) IUTEST_TEST_COMPILEERROR(e)
641 #else
642 # define IUTEST_TEST_STATICASSERT(e) IUTEST_TEST_COMPILEERROR("static_assert")
643 #endif
644 
648 #endif // INCG_IRIS_IUTEST_INTERNAL_HPP_A5BD9FBB_B57A_4C1D_B205_0ADB7798DBF9_
iutest_config.hpp
iris unit test config