iutest  1.17.1.0
iutest_assertion.hpp
[詳解]
1 //======================================================================
2 //-----------------------------------------------------------------------
13 //-----------------------------------------------------------------------
14 //======================================================================
15 #ifndef INCG_IRIS_IUTEST_ASSERTION_HPP_E6AF3476_DA81_46F7_A961_ACCEF7363932_
16 #define INCG_IRIS_IUTEST_ASSERTION_HPP_E6AF3476_DA81_46F7_A961_ACCEF7363932_
17 
18 //======================================================================
19 // include
20 #include "iutest_result.hpp"
21 #include "iutest_printers.hpp"
22 #include "internal/iutest_list.hpp"
23 
24 namespace iutest
25 {
26 
27 //======================================================================
28 // typedef
30 typedef detail::iuStreamMessage Message;
31 
32 //======================================================================
33 // function
34 template<typename T>
35 inline ::std::string StreamableToString(const T& value)
36 {
37  return (Message() << value).GetString();
38 }
39 
40 //======================================================================
41 // declare
42 namespace detail
43 {
45  void DefaultReportTestPartResult(const TestPartResult& test_part_result);
46 }
47 
48 //======================================================================
49 // class
53 class AssertionResult
54 {
55 public:
60  AssertionResult(bool result) : m_result(result) {} // NOLINT
62  AssertionResult(const AssertionResult& rhs) : m_message(rhs.m_message), m_result(rhs.m_result) {}
63 
67  bool failed() const IUTEST_CXX_NOEXCEPT_SPEC { return !m_result; }
68 
72  bool passed() const IUTEST_CXX_NOEXCEPT_SPEC { return m_result; }
73 
77  const char* message() const { return m_message.c_str(); }
78 
83  const char* failure_message() const { return message(); }
84 
86  IUTEST_CXX_EXPLICIT_CONVERSION operator bool() const { return m_result; }
87 
88 public:
92  template<typename T>
93  AssertionResult& operator << (const T& value)
94  {
95  Message msg;
96  msg << value;
97  m_message += msg.GetString();
98  return *this;
99  }
100 public:
101  AssertionResult operator ! () const
102  {
103  return AssertionResult(failed()) << message();
104  }
105  AssertionResult operator && (const AssertionResult& rhs) const
106  {
107  return AssertionResult(m_result && rhs.passed()) << message() << " && " << rhs.message();
108  }
109  AssertionResult operator || (const AssertionResult& rhs) const
110  {
111  return AssertionResult(m_result || rhs.passed()) << message() << " || " << rhs.message();
112  }
113 
114 public:
118  static AssertionResult Success() { return AssertionResult(true); }
122  static AssertionResult Failure() { return AssertionResult(false); }
126  template<typename T>
127  static AssertionResult Is(const T& b) { return AssertionResult(b ? true : false); }
129  static AssertionResult Is(const AssertionResult& ar) { return AssertionResult(ar); }
130 
131 private:
132  IUTEST_PP_DISALLOW_ASSIGN(AssertionResult);
133 
134  ::std::string m_message;
135  bool m_result;
136 };
137 
138 #if IUTEST_HAS_ASSERTION_RETURN
139 
142 template<typename R>
143 struct AssertionReturnType
144 {
145  R value;
152  AssertionReturnType(const R& v) : value(v) {} // NOLINT
153 };
157 template<>
158 struct AssertionReturnType<void>
159 {
162 };
163 
167 template<typename T>
168 inline AssertionReturnType<T> AssertionReturn(const T& ret) { return AssertionReturnType<T>(ret); }
169 
172 
173 #endif
174 
179 class AssertionHelper
180 {
181 public:
189  AssertionHelper(const char* file, int line, const char* message, TestPartResult::Type type)
190  : m_part_result(file, line, message, type)
191  {}
199  AssertionHelper(const char* file, int line, const ::std::string& message, TestPartResult::Type type)
200  : m_part_result(file, line, message.c_str(), type)
201  {}
202 
203 public:
205  class ScopedMessage
206  : public detail::iuCodeMessage
207 #if IUTEST_USE_OWN_LIST
208  , public detail::iu_list_node<ScopedMessage>
209 #endif
210  {
211  public:
212  ScopedMessage(const detail::iuCodeMessage& msg) // NOLINT
213  : detail::iuCodeMessage(msg)
214  {
215  ScopedTrace::GetInstance().list.push_back(this);
216  }
217  ~ScopedMessage()
218  {
219  ScopedTrace::GetInstance().list.remove(this);
220  }
221  };
222 private:
223  class ScopedTrace
224  {
225  public:
226 #if IUTEST_USE_OWN_LIST
227  typedef detail::iu_list<ScopedMessage> msg_list;
228 #else
229  typedef ::std::list<ScopedMessage*> msg_list;
230 #endif
231  msg_list list;
232  static ScopedTrace& GetInstance() { static ScopedTrace inst; return inst; }
233  public:
234  void append_message(TestPartResult& part_result)
235  {
236  if( list.size() )
237  {
238  part_result.add_message("\niutest trace:");
239  for( msg_list::iterator it = list.begin(), end=list.end(); it != end; ++it )
240  {
241  // TODO : 追加メッセージとして保存するべき
242  // 現状はテスト結果のメッセージに追加している。
243  part_result.add_message("\n");
244  part_result.add_message((*it)->make_message().c_str());
245  }
246  }
247  }
248  };
249 
250 #if defined(IUTEST_NO_PRIVATE_IN_AGGREGATE)
251  friend class ScopedMessage;
252 #endif
253 
254 #if IUTEST_HAS_ASSERTION_RETURN
255 private:
256  template<typename R>struct ReturnTypedFixed;
257 #endif
258 
259 public:
261  class Fixed : public Message
262  {
263  public:
264  template<typename T>
265  Fixed& operator << (T val)
266  {
267  Message::operator << (val);
268  return *this;
269  }
270  template<typename T, size_t SIZE>
271  Fixed& operator << (const T(&val)[SIZE])
272  {
273  Message::operator << (val);
274  return *this;
275  }
276 #if IUTEST_HAS_IOMANIP
277  Fixed& operator << (iu_basic_iomanip val)
278  {
279  Message::operator << (val);
280  return *this;
281  }
282 #endif
283 #if IUTEST_HAS_ASSERTION_RETURN
284  Fixed& operator << (const AssertionReturnType<void>&)
285  {
286  return *this;
287  }
288  template<typename R>
289  ReturnTypedFixed<R> operator << (const AssertionReturnType<R>& ret)
290  {
291  return ReturnTypedFixed<R>(*this, ret);
292  }
293 #endif
294  };
295 
296 #if IUTEST_HAS_ASSERTION_RETURN
297 private:
298  template<typename R>
299  struct ReturnTypedFixed
300  {
301  Fixed fixed;
303  ReturnTypedFixed(const Fixed& f, const AssertionReturnType<R>& r) : fixed(f), ret(r) {}
304  };
305 #endif
306 
307 public:
309  void operator = (const Fixed& fixed)
310  {
311  OnFixed(fixed);
312 #if IUTEST_HAS_EXCEPTIONS && IUTEST_USE_THROW_ON_ASSERTION_FAILURE
313  {
314  switch( m_part_result.type() )
315  {
319  throw m_part_result.type();
320  default:
321  break;
322  }
323  }
324 #endif
325  }
326 #if IUTEST_HAS_ASSERTION_RETURN
327 
328  template<typename R>
329  R operator = (const ReturnTypedFixed<R>& fixed) // lgtm [cpp/assignment-does-not-return-this]
330  {
331  this->operator=(fixed.fixed);
332  return fixed.ret.value;
333  }
334 #endif
335 
336 private:
337  void OnFixed(const Fixed& fixed)
338  {
339  // OnFixed で throw しないこと!テスト側の例外キャッチにかからなくなる
340  const ::std::string append_message = fixed.GetString();
341  if( !append_message.empty() )
342  {
343  m_part_result.add_message(" " + append_message);
344  }
345  ScopedTrace::GetInstance().append_message(m_part_result);
346 
347  if( TestEnv::GetGlobalTestPartResultReporter() != IUTEST_NULLPTR )
348  {
349  TestEnv::GetGlobalTestPartResultReporter()->ReportTestPartResult(m_part_result);
350  }
351  else
352  {
353  detail::DefaultReportTestPartResult(m_part_result);
354  }
355 
356  if( m_part_result.failed()
358  {
359  IUTEST_BREAK();
360  }
361  }
362 
363 private:
364  friend class TestInfo;
365  TestPartResult m_part_result;
366 
367 private:
369 };
370 
371 } // end of namespace iutest
372 
373 namespace iutest
374 {
375 
376 //======================================================================
377 // function
381 inline AssertionResult AssertionSuccess() { return AssertionResult::Success(); }
385 inline AssertionResult AssertionFailure() { return AssertionResult::Failure(); }
386 
390 inline const char* GetAssertionResultMessage(const AssertionResult& ar)
391 {
392  return ar.message();
393 }
394 
395 namespace internal
396 {
397 
401 template<typename T1, typename T2>
402 inline ::std::string FormatForComparisonFailureMessage(const T1& value, const T2& /*other_operand*/)
403 {
404  return PrintToString(value);
405 }
406 
410 inline ::std::string GetBooleanAssertionFailureMessage(const AssertionResult& ar
411  , const char* expr, const char* actual, const char* expected)
412 {
413  ::std::string str = "error: Value of: ";
414  str += expr;
415  str += "\n Actual: ";
416  str += actual;
417  if( !detail::IsEmpty(ar.message()) )
418  {
419  str += " (";
420  str += ar.message();
421  str += ")";
422  }
423  str += "\nExpected: ";
424  str += expected;
425  return str;
426 }
427 
431 inline AssertionResult EqFailure(const char* expected_expression, const char* actual_expression
432  , const ::std::string& expected, const ::std::string& actual, bool ignoring_case = false)
433 {
434  iu_global_format_stringstream strm;
435  strm << "error: Value of " << actual_expression
436  << "\n Actual: " << actual
437  << "\nExpected: " << expected_expression;
438  if( ignoring_case )
439  {
440  strm << " (ignoring case)";
441  }
442  if( !detail::IsStringEqual(expected_expression, expected.c_str()) )
443  {
444  strm << "\nWhich is: " << expected;
445  }
446  return AssertionFailure() << strm.str();
447 }
448 
449 template<typename T1, typename T2>
450 inline AssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2, const char* op
451  , const T1& val1, const T2& val2)
452 {
453  return AssertionFailure() << "error: Expected: " << expr1 << " " << op << " " << expr2
454  << "\n Actual: " << FormatForComparisonFailureMessage(val1, val2)
455  << " vs " << FormatForComparisonFailureMessage(val2, val1);
456 }
457 
463 #define IIUT_DECL_COMPARE_HELPER_EXTEND_POINT_BASE_(op_name, op) \
464  template<typename T1, typename T2> \
465  bool iuOperator##op_name(const T1& v1, const T2& v2) { \
466  return v1 op v2; \
467  }
468 
469 #if IUTEST_HAS_CXX_HDR_VARIANT && IUTEST_HAS_VARIADIC_TEMPLATES
470 #define IIUT_DECL_COMPARE_HELPER_EXTEND_POINT_VARIANT_(op_name, op) \
471  template<typename ...V1, typename ...V2> \
472  bool iuOperator##op_name(const ::std::variant<V1...>&& v1, const ::std::variant<V2...>& v2) { \
473  return v1 op v2; \
474  } \
475  template<typename T1, typename ...V> \
476  bool iuOperator##op_name(const T1& v1, const ::std::variant<V...>& v2 \
477  , typename detail::enable_if< !detail::is_variant<T1>::value, void>::type*& = detail::enabler::value ) { \
478  ::std::variant<V...> vv1(v1); return vv1 op v2; \
479  } \
480  template<typename ...V, typename T2> \
481  bool iuOperator##op_name(const ::std::variant<V...>& v1, const T2& v2 \
482  , typename detail::enable_if< !detail::is_variant<T2>::value, void>::type*& = detail::enabler::value ) { \
483  ::std::variant<V...> vv2(v2); return v1 op vv2; \
484  }
485 #else
486 #define IIUT_DECL_COMPARE_HELPER_EXTEND_POINT_VARIANT_(op_name, op)
487 #endif
488 
489 #define IIUT_DECL_COMPARE_HELPER_EXTEND_POINT_(op_name, op) \
490  IIUT_DECL_COMPARE_HELPER_EXTEND_POINT_BASE_(op_name, op) \
491  IIUT_DECL_COMPARE_HELPER_EXTEND_POINT_VARIANT_(op_name, op)
492 
493 #define IIUT_DECL_COMPARE_HELPER_I_(op_name, op, type1, type2) \
494  inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelper##op_name( \
495  const char* expr1, const char* expr2, type1 val1, type2 val2) { \
496  if( iuOperator##op_name(val1, val2) ) { return AssertionSuccess(); \
497  } else { return CmpHelperOpFailure(expr1, expr2, #op, val1, val2); } \
498  }
499 
500 #if !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING)
501 
502 #define IIUT_DECL_COMPARE_HELPER_(op_name, op) \
503  IIUT_DECL_COMPARE_HELPER_EXTEND_POINT_(op_name, op) \
504  template<typename T1, typename T2> \
505  IIUT_DECL_COMPARE_HELPER_I_(op_name, op, const T1&, const T2&) \
506  IIUT_DECL_COMPARE_HELPER_I_(op_name, op, BiggestInt, BiggestInt)
507 
508 #else
509 
510 #define IIUT_DECL_COMPARE_HELPER_(op_name, op) \
511  IIUT_DECL_COMPARE_HELPER_EXTEND_POINT_(op_name, op) \
512  template<typename T1, typename T2> \
513  IIUT_DECL_COMPARE_HELPER_I_(op_name, op, const T1&, const T2&)
514 
515 #endif
516 
517 template<typename T1, typename T2>
518 bool iuOperatorEQ(const T1& v1, const T2& v2)
519 {
520 IUTEST_PRAGMA_WARN_PUSH()
521 IUTEST_PRAGMA_WARN_DISABLE_SIGN_COMPARE()
522  return v1 == v2;
523 IUTEST_PRAGMA_WARN_POP()
524 }
525 IIUT_DECL_COMPARE_HELPER_EXTEND_POINT_VARIANT_(EQ, ==)
526 
527 IIUT_DECL_COMPARE_HELPER_(NE, !=)
528 IIUT_DECL_COMPARE_HELPER_(LE, <=)
529 IIUT_DECL_COMPARE_HELPER_(LT, < )
530 IIUT_DECL_COMPARE_HELPER_(GE, >=)
531 IIUT_DECL_COMPARE_HELPER_(GT, > )
532 
533 
534 #undef IIUT_DECL_COMPARE_HELPER_EXTEND_POINT_
535 #undef IIUT_DECL_COMPARE_HELPER_EXTEND_POINT_BASE
536 #undef IIUT_DECL_COMPARE_HELPER_EXTEND_POINT_VARIANT
537 #undef IIUT_DECL_COMPARE_HELPER_I_
538 #undef IIUT_DECL_COMPARE_HELPER_
539 
548 template<bool IsNullLiteral>
549 class NullHelper
550 {
551 public:
552  template<typename T>
553  static AssertionResult CompareEq(const char* expr, const T* val)
554  {
555  if( IUTEST_NULLPTR == val )
556  {
557  return AssertionSuccess();
558  }
559 
560  return AssertionFailure() << "error: Value of " << expr
561  << "\n Actual: " << val
562  << "\nExpected: NULL";
563  }
564  template<typename T>
565  static AssertionResult CompareNe(const char* expr, const T* val)
566  {
567  if( IUTEST_NULLPTR != val )
568  {
569  return AssertionSuccess();
570  }
571 
572  return AssertionFailure() << "error: Value of " << expr
573  << "\n Actual: NULL\nExpected: not NULL";
574  }
575 };
576 
580 template<>
581 class NullHelper<true>
582 {
583 public:
584  static AssertionResult CompareEq(const char*, void*)
585  {
586  return AssertionSuccess();
587  }
588  static AssertionResult CompareNe(const char* expr, void*)
589  {
590  return AssertionFailure() << "error: Value of " << expr
591  << "\n Actual: NULL\nExpected: not NULL";
592  }
593 };
594 
595 template<typename T1, typename T2>
596 inline AssertionResult CmpHelperSame(const char* expected_str, const char* actual_str
597  , const T1& expected, const T2& actual)
598 {
599  if( &expected == &actual )
600  {
601  return AssertionSuccess();
602  }
603 
604  return AssertionFailure() << "error: Expected: &(" << expected_str << ") == &(" << actual_str
605  << ")\n Actual: " << FormatForComparisonFailureMessage(&expected, &actual)
606  << " vs " << FormatForComparisonFailureMessage(&actual, &expected);
607 }
608 
609 template<typename T1, typename T2>
610 inline AssertionResult CmpHelperEQ(const char* expected_str, const char* actual_str
611  , const T1& expected, const T2& actual)
612 {
613  if( iuOperatorEQ(actual, expected) )
614  {
615  return AssertionSuccess();
616  }
617 
618  return EqFailure(expected_str, actual_str
619  , FormatForComparisonFailureMessage(expected, actual)
620  , FormatForComparisonFailureMessage(actual, expected)
621  );
622 }
623 
624 template<typename T>
625 inline AssertionResult CmpHelperMemCmpEQ(const char* expected_str, const char* actual_str
626  , const T& expected, const T& actual)
627 {
628 IUTEST_PRAGMA_WARN_PUSH()
629 IUTEST_PRAGMA_WARN_DISABLE_SIGN_COMPARE()
630 
631  if( memcmp(&actual, &expected, sizeof(T)) == 0 )
632  {
633  return AssertionSuccess();
634  }
635 
636  return EqFailure(expected_str, actual_str
637  , FormatForComparisonFailureMessage(expected, actual)
638  , FormatForComparisonFailureMessage(actual, expected)
639  );
640 
641 IUTEST_PRAGMA_WARN_POP()
642 }
643 
644 template<typename T>
645 inline AssertionResult CmpHelperMemCmpNE(const char* expected_str, const char* actual_str
646  , const T& expected, const T& actual)
647 {
648 IUTEST_PRAGMA_WARN_PUSH()
649 IUTEST_PRAGMA_WARN_DISABLE_SIGN_COMPARE()
650 
651  if( memcmp(&actual, &expected, sizeof(T)) != 0 )
652  {
653  return AssertionSuccess();
654  }
655 
656  return AssertionFailure() << "error: Expected: " << expected_str << " != " << actual_str
657  << "\n Actual: " << FormatForComparisonFailureMessage(expected, actual);
658 
659 IUTEST_PRAGMA_WARN_POP()
660 }
661 
662 template<typename RawType>
663 inline AssertionResult CmpHelperFloatingPointEQ(const char* expr1, const char* expr2
664  , RawType val1, RawType val2)
665 {
666  floating_point<RawType> f1(val1), f2(val2);
667  if( f1.AlmostEquals(f2) )
668  {
669  return AssertionSuccess();
670  }
671  return EqFailure(expr1, expr2
672  , detail::ShowStringQuoted(FormatForComparisonFailureMessage(f1, f2))
673  , detail::ShowStringQuoted(FormatForComparisonFailureMessage(f2, f1)));
674 }
675 
676 template<typename RawType>
677 inline AssertionResult CmpHelperFloatingPointLE(const char* expr1, const char* expr2
678  , RawType val1, RawType val2)
679 {
680  if( val1 < val2 )
681  {
682  return AssertionSuccess();
683  }
684  floating_point<RawType> f1(val1), f2(val2);
685  if( f1.AlmostEquals(f2) )
686  {
687  return AssertionSuccess();
688  }
689  return EqFailure(expr1, expr2
690  , detail::ShowStringQuoted(FormatForComparisonFailureMessage(f1, f2))
691  , detail::ShowStringQuoted(FormatForComparisonFailureMessage(f2, f1)));
692 }
693 
697 namespace backward
698 {
699 
704 template<bool IsNullLiteral>
705 class EqHelper
706 {
707 #if IUTEST_HAS_ASSERTION_NOEQUALTO_OBJECT
708  template<typename T, bool has_equal_to_operator>
709  struct CmpHelper
710  {
711  static AssertionResult Compare(const char* expr1, const char* expr2, const T& val1, const T& val2)
712  {
713  return CmpHelperEQ(expr1, expr2, val1, val2);
714  }
715  };
716  template<typename T>
717  struct CmpHelper<T, false>
718  {
719  static AssertionResult Compare(const char* expr1, const char* expr2, const T& val1, const T& val2)
720  {
721  return CmpHelperMemCmpEQ(expr1, expr2, val1, val2);
722  }
723  };
724 
725 public:
726  template<typename T>
727  static AssertionResult Compare(const char* expr1, const char* expr2, const T& val1, const T& val2)
728  {
729  return CmpHelper<T, detail::has_equal_to<T>::value>::Compare(expr1, expr2, val1, val2);
730  }
731 #endif
732 
733 public:
734  template<typename T1, typename T2>
735  static AssertionResult Compare(const char* expr1, const char* expr2, const T1& val1, const T2& val2)
736  {
737  return CmpHelperEQ(expr1, expr2, val1, val2);
738  }
739 };
740 
744 template<>
745 class EqHelper<true>
746 {
747 public:
748 #if !defined(IUTEST_NO_SFINAE)
749  template<typename T1, typename T2>
750  static AssertionResult Compare(const char* expr1, const char* expr2, const T1& val1, const T2& val2
751  , typename detail::enable_if< !detail::is_pointer<T2>::value, void>::type*& = detail::enabler::value)
752  {
753  return CmpHelperEQ(expr1, expr2, val1, val2);
754  }
755  template<typename T2>
756  static AssertionResult Compare(const char* expr1, const char* expr2
757  , detail::IsNullLiteralHelper::Object* val1, T2* val2)
758  {
759  IUTEST_UNUSED_VAR(val1);
760  return CmpHelperEQ(expr1, expr2, static_cast<T2*>(IUTEST_NULLPTR), val2);
761  }
762 #else
763  template<typename T1, typename T2>
764  static AssertionResult Compare(const char* expr1, const char* expr2, const T1& val1, const T2& val2)
765  {
766  return CmpHelperEQ(expr1, expr2, (T2)(val1), val2); // NOLINT
767  }
768 #endif
769 };
770 
775 template<bool IsNullLiteral>
776 class AlmostEqHelper : public EqHelper<false>
777 {
778 public:
779  template<typename T1, typename T2>
780  static AssertionResult Compare(const char* expr1, const char* expr2, const T1& val1, const T2& val2)
781  {
782  return EqHelper<false>::Compare(expr1, expr2, val1, static_cast<T1>(val2));
783  }
784  template<typename T>
785  static AssertionResult Compare(const char* expr1, const char* expr2, const float& val1, const T& val2)
786  {
787  return CmpHelperFloatingPointEQ<float>(expr1, expr2, val1, static_cast<float>(val2));
788  }
789  template<typename T>
790  static AssertionResult Compare(const char* expr1, const char* expr2, const double& val1, const T& val2)
791  {
792  return CmpHelperFloatingPointEQ<double>(expr1, expr2, val1, static_cast<double>(val2));
793  }
794 };
795 
799 template<>
800 class AlmostEqHelper<true> : public EqHelper<true>
801 {
802 };
803 
808 template<bool IsNullLiteral>
809 class NeHelper
810 {
811 #if IUTEST_HAS_ASSERTION_NOEQUALTO_OBJECT
812  template<typename T, bool has_not_equal_to_operator>
813  struct CmpHelper
814  {
815  static AssertionResult Compare(const char* expr1, const char* expr2, const T& val1, const T& val2)
816  {
817  return CmpHelperNE(expr1, expr2, val1, val2);
818  }
819  };
820  template<typename T>
821  struct CmpHelper<T, false>
822  {
823  static AssertionResult Compare(const char* expr1, const char* expr2, const T& val1, const T& val2)
824  {
825  return CmpHelperMemCmpNE(expr1, expr2, val1, val2);
826  }
827  };
828 
829 public:
830  template<typename T>
831  static AssertionResult Compare(const char* expr1, const char* expr2, const T& val1, const T& val2)
832  {
833  return CmpHelper<T, detail::has_not_equal_to<T>::value>::Compare(expr1, expr2, val1, val2);
834  }
835 
836 #endif
837 
838 public:
839  template<typename T1, typename T2>
840  static AssertionResult Compare(const char* expr1, const char* expr2, const T1& val1, const T2& val2)
841  {
842  return CmpHelperNE(expr1, expr2, val1, val2);
843  }
844 };
845 
849 template<>
850 class NeHelper<true>
851 {
852 public:
853 #if !defined(IUTEST_NO_SFINAE)
854  template<typename T1, typename T2>
855  static AssertionResult Compare(const char* expr1, const char* expr2, const T1& val1, const T2& val2
856  , typename detail::enable_if< !detail::is_pointer<T2>::value, void>::type*& = detail::enabler::value)
857  {
858  return CmpHelperNE(expr1, expr2, val1, val2);
859  }
860  template<typename T2>
861  static AssertionResult Compare(const char* expr1, const char* expr2
862  , detail::IsNullLiteralHelper::Object* val1, T2* val2)
863  {
864  IUTEST_UNUSED_VAR(val1);
865  return CmpHelperNE(expr1, expr2, static_cast<T2*>(IUTEST_NULLPTR), val2);
866  }
867 #else
868  template<typename T1, typename T2>
869  static AssertionResult Compare(const char* expr1, const char* expr2, const T1& val1, const T2& val2)
870  {
871  return CmpHelperNE(expr1, expr2, (T2)(val1), val2); // NOLINT
872  }
873 #endif
874 };
875 
876 } // end of namespace backward
877 
878 #if IUTEST_HAS_NULLPTR && IUTEST_HAS_CXX_HDR_TYPE_TARITS && 0
879 
883 class EqHelper
884 {
885  template<typename T1, typename T2, typename detail::enable_if<
886  !detail::is_integral<T1>::value || !detail::is_pointer<T2>::value, void>::type*& = detail::enabler::value>
887  static AssertionResult Compare(const char* expr1, const char* expr2, const T1& val1, const T2& val2)
888  {
889  return backward::EqHelper<false>::Compare(expr1, expr2, val1, val2);
890  }
891  template<typename T>
892  static AssertionResult Compare(const char* expr1, const char* expr2, ::std::nullptr_t, T* val2)
893  {
894  return CmpHelperEQ(expr1, expr2, static_cast<T*>(IUTEST_NULLPTR), val2);
895  }
896 };
897 
901 class NeHelper
902 {
903  template<typename T1, typename T2, typename detail::enable_if<
904  !detail::is_integral<T1>::value || !detail::is_pointer<T2>::value, void>::type*& = detail::enabler::value>
905  static AssertionResult Compare(const char* expr1, const char* expr2, const T1& val1, const T2& val2)
906  {
907  return backward::NeHelper<false>::Compare(expr1, expr2, val1, val2);
908  }
909  template<typename T>
910  static AssertionResult Compare(const char* expr1, const char* expr2, ::std::nullptr_t, T* val2)
911  {
912  return CmpHelperNE(expr1, expr2, static_cast<T*>(IUTEST_NULLPTR), val2);
913  }
914 };
915 
916 #else
917 
918 using backward::EqHelper;
919 using backward::AlmostEqHelper;
920 using backward::NeHelper;
921 
922 #endif
923 
924 template<typename RawType>
925 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperNearFloatingPoint(
926  const char* expr1, const char* expr2, const char* absc
927  , RawType val1, RawType val2, RawType abs_v)
928 {
929  RawType diff = val1 > val2 ? val1 - val2 : val2 - val1;
930  if( diff < abs_v )
931  {
932  return AssertionSuccess();
933  }
934  floating_point<RawType> f1(diff), f2(abs_v);
935  if( f1.AlmostEquals(f2) )
936  {
937  return AssertionSuccess();
938  }
939  return AssertionFailure() << "error: Value of: abs(" << expr1 << " - " << expr2 << ") <= " << absc
940  << "\n Actual: abs(" << val1 << " - " << val2 << ") : " << diff
941  << "\nExpected: " << FormatForComparisonFailureMessage(abs_v, diff);
942 }
943 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ DoubleNearPredFormat(
944  const char* expr1, const char* expr2, const char* absc
945  , double val1, double val2, double abs_v)
946 {
947  return CmpHelperNearFloatingPoint(expr1, expr2, absc, val1, val2, abs_v);
948 }
949 #if !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING)
950 template<typename T, typename A>
951 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperNear(
952  const char* expr1, const char* expr2, const char* absc
953  , const T& val1, const T& val2, const A& abs_v)
954 {
955  T diff = val1 > val2 ? val1 - val2 : val2 - val1;
956  if( diff <= abs_v )
957  {
958  return AssertionSuccess();
959  }
960  return AssertionFailure() << "error: Value of: abs(" << expr1 << " - " << expr2 << ") <= " << absc
961  << "\n Actual: abs(" << val1 << " - " << val2 << ") : " << diff
962  << "\nExpected: " << FormatForComparisonFailureMessage(abs_v, diff);
963 }
964 template<typename A>
965 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperNear(
966  const char* expr1, const char* expr2, const char* absc
967  , double val1, double val2, const A& abs_v)
968 {
969  return CmpHelperNearFloatingPoint<double>(expr1, expr2, absc, val1, val2, static_cast<double>(abs_v));
970 }
971 #endif
972 template<typename A>
973 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperNear(
974  const char* expr1, const char* expr2, const char* absc
975  , float val1, float val2, const A& abs_v)
976 {
977  return CmpHelperNearFloatingPoint<float>(expr1, expr2, absc, val1, val2, static_cast<float>(abs_v));
978 }
979 
980 
981 namespace StrEqHelper
982 {
983 
984 #if IUTEST_HAS_NULLPTR && 0
985 #define IIUT_DECL_STREQ_COMPARE_HELPER_NULL_(T) \
986  inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(::std::nullptr_t, const T* val2) { \
987  return val2 == IUTEST_NULLPTR; \
988  }
989 #else
990 #define IIUT_DECL_STREQ_COMPARE_HELPER_NULL_(T)
991 #endif
992 
993 #define IIUT_DECL_STREQ_COMPARE_HELPER_SV_(T) \
994  inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(detail::iu_nullable_basic_string_view<T> val1 \
995  , detail::iu_nullable_basic_string_view<T> val2) { \
996  return val1 == val2; \
997  } \
998  inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const T* val1, const T* val2) { \
999  if( val1 == IUTEST_NULLPTR || val2 == IUTEST_NULLPTR ) { return val1 == val2; } \
1000  return Compare(detail::iu_nullable_basic_string_view<T>(val1) \
1001  , detail::iu_nullable_basic_string_view<T>(val2)); \
1002  }
1003 
1004 #define IIUT_DECL_STREQ_COMPARE_HELPER_(T) \
1005  IIUT_DECL_STREQ_COMPARE_HELPER_SV_(T) \
1006  IIUT_DECL_STREQ_COMPARE_HELPER_NULL_(T)
1007 
1008 IIUT_DECL_STREQ_COMPARE_HELPER_(char)
1009 IIUT_DECL_STREQ_COMPARE_HELPER_(wchar_t)
1010 #if IUTEST_HAS_CHAR16_T
1011 IIUT_DECL_STREQ_COMPARE_HELPER_(char16_t)
1012 #endif
1013 #if IUTEST_HAS_CHAR32_T
1014 IIUT_DECL_STREQ_COMPARE_HELPER_(char32_t)
1015 #endif
1016 
1017 #undef IIUT_DECL_STREQ_COMPARE_HELPER_
1018 #undef IIUT_DECL_STREQ_COMPARE_HELPER_SV_
1019 
1020 } // end of namespace StrEqHelper
1021 
1022 template<typename T1, typename T2>
1023 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTREQ(
1024  const char* expr1, const char* expr2
1025  , T1 val1, T2 val2, typename detail::enable_if<
1026  !detail::is_integral<T1>::value || !detail::is_pointer<T2>::value, void>::type*& = detail::enabler::value)
1027 {
1028  if( StrEqHelper::Compare(val1, val2) )
1029  {
1030  return AssertionSuccess();
1031  }
1032 
1033  return EqFailure(expr1, expr2
1034  , detail::ShowStringQuoted(FormatForComparisonFailureMessage(val1, val2))
1035  , detail::ShowStringQuoted(FormatForComparisonFailureMessage(val2, val1)));
1036 }
1037 
1038 template<typename T>
1039 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTREQ(
1040  const char* expr1, const char* expr2
1041  , detail::iu_nullptr_convertible_t, T val2)
1042 {
1043  if( StrEqHelper::Compare(IUTEST_NULLPTR, val2) )
1044  {
1045  return AssertionSuccess();
1046  }
1047 
1048  return EqFailure(expr1, expr2
1049  , detail::ShowStringQuoted(FormatForComparisonFailureMessage<T, T>(IUTEST_NULLPTR, val2))
1050  , detail::ShowStringQuoted(FormatForComparisonFailureMessage<T, T>(val2, IUTEST_NULLPTR)));
1051 }
1052 
1053 namespace StrNeHelper
1054 {
1055 
1056 template<typename T1, typename T2>
1057 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const T1& val1, const T2& val2)
1058 {
1059  return !StrEqHelper::Compare(val1, val2);
1060 }
1061 
1062 } // end of namespace StrNeHelper
1063 
1064 template<typename T1, typename T2>
1065 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRNE(
1066  const char* expr1, const char* expr2
1067  , T1 val1, T2 val2, typename detail::enable_if<
1068  ((!detail::is_integral<T2>::value || !detail::is_pointer<T1>::value) &&
1069  (!detail::is_integral<T1>::value || !detail::is_pointer<T2>::value)), void>::type*& = detail::enabler::value)
1070 {
1071  if( StrNeHelper::Compare(val1, val2) )
1072  {
1073  return AssertionSuccess();
1074  }
1075 
1076  return AssertionFailure() << "error: Expected: " << expr1 << " != " << expr2
1077  << "\n Actual: " << detail::ShowStringQuoted(FormatForComparisonFailureMessage(val2, val1))
1078  << " vs " << detail::ShowStringQuoted(FormatForComparisonFailureMessage(val1, val2));
1079 }
1080 
1081 template<typename T>
1082 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRNE(
1083  const char* expr1, const char* expr2
1084  , detail::iu_nullptr_convertible_t, T val2)
1085 {
1086  if( !StrEqHelper::Compare(IUTEST_NULLPTR, val2) )
1087  {
1088  return AssertionSuccess();
1089  }
1090 
1091  return AssertionFailure() << "error: Expected: " << expr1 << " != " << expr2
1092  << "\n Actual: " << detail::ShowStringQuoted(FormatForComparisonFailureMessage<T, T>(val2, IUTEST_NULLPTR))
1093  << " vs " << detail::ShowStringQuoted(FormatForComparisonFailureMessage<T, T>(IUTEST_NULLPTR, val2));
1094 }
1095 
1096 template<typename T>
1097 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRNE(
1098  const char* expr1, const char* expr2
1099  , T val1, detail::iu_nullptr_convertible_t)
1100 {
1101  if( !StrEqHelper::Compare(val1, IUTEST_NULLPTR) )
1102  {
1103  return AssertionSuccess();
1104  }
1105 
1106  return AssertionFailure() << "error: Expected: " << expr1 << " != " << expr2
1107  << "\n Actual: " << detail::ShowStringQuoted(FormatForComparisonFailureMessage<T, T>(IUTEST_NULLPTR, val1))
1108  << " vs " << detail::ShowStringQuoted(FormatForComparisonFailureMessage<T, T>(val1, IUTEST_NULLPTR));
1109 }
1110 
1111 namespace StrCaseEqHelper
1112 {
1113 
1114 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const char* val1, const char* val2)
1115 {
1116  if( val1 == IUTEST_NULLPTR || val2 == IUTEST_NULLPTR )
1117  {
1118  return val1 == val2;
1119  }
1120  return detail::iu_stricmp(val1, val2) == 0;
1121 }
1122 
1123 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const wchar_t* val1, const wchar_t* val2)
1124 {
1125  if( val1 == IUTEST_NULLPTR || val2 == IUTEST_NULLPTR )
1126  {
1127  return val1 == val2;
1128  }
1129  return detail::iu_wcsicmp(val1, val2) == 0;
1130 }
1131 
1132 template<typename Elem, typename Traits, typename Ax>
1133 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(
1134  const ::std::basic_string<Elem, Traits, Ax>& val1
1135  , const ::std::basic_string<Elem, Traits, Ax>& val2)
1136 {
1137  return Compare(val1.c_str(), val2.c_str());
1138 }
1139 template<typename Elem, typename Traits, typename Ax>
1140 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(
1141  const Elem* val1
1142  , const ::std::basic_string<Elem, Traits, Ax>& val2)
1143 {
1144  return Compare(val1, val2.c_str());
1145 }
1146 template<typename Elem, typename Traits, typename Ax>
1147 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(
1148  const ::std::basic_string<Elem, Traits, Ax>& val1
1149  , const Elem* val2)
1150 {
1151  return Compare(val1.c_str(), val2);
1152 }
1153 
1154 template<typename T1, typename T2>
1155 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ Assertion(
1156  const char* expr1, const char* expr2
1157  , const T1& val1, const T2& val2)
1158 {
1159  if( Compare(val1, val2) )
1160  {
1161  return AssertionSuccess();
1162  }
1163 
1164  return EqFailure(expr1, expr2
1165  , detail::ShowStringQuoted(FormatForComparisonFailureMessage(val1, val2))
1166  , detail::ShowStringQuoted(FormatForComparisonFailureMessage(val2, val1))
1167  , true);
1168 }
1169 
1170 } // end of namespace StrCaseEqHelper
1171 
1172 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRCASEEQ(
1173  const char* expr1, const char* expr2
1174  , const char* val1, const char* val2)
1175 {
1176  return StrCaseEqHelper::Assertion(expr1, expr2, val1, val2);
1177 }
1178 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRCASEEQ(
1179  const char* expr1, const char* expr2
1180  , const wchar_t* val1, const wchar_t* val2)
1181 {
1182  return StrCaseEqHelper::Assertion(expr1, expr2, val1, val2);
1183 }
1184 template<typename Elem, typename Traits, typename Ax>
1185 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRCASEEQ(
1186  const char* expr1, const char* expr2
1187  , const ::std::basic_string<Elem, Traits, Ax>& val1
1188  , const ::std::basic_string<Elem, Traits, Ax>& val2)
1189 {
1190  return CmpHelperSTRCASEEQ(expr1, expr2, val1.c_str(), val2.c_str());
1191 }
1192 template<typename Elem, typename Traits, typename Ax>
1193 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRCASEEQ(
1194  const char* expr1, const char* expr2
1195  , const Elem* val1, const ::std::basic_string<Elem, Traits, Ax>& val2)
1196 {
1197  return CmpHelperSTRCASEEQ(expr1, expr2, val1, val2.c_str());
1198 }
1199 template<typename Elem, typename Traits, typename Ax>
1200 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRCASEEQ(
1201  const char* expr1, const char* expr2
1202  , const ::std::basic_string<Elem, Traits, Ax>& val1, const Elem* val2)
1203 {
1204  return CmpHelperSTRCASEEQ(expr1, expr2, val1.c_str(), val2);
1205 }
1206 
1207 namespace StrCaseNeHelper
1208 {
1209 
1210 template<typename T1, typename T2>
1211 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const T1& val1, const T2& val2)
1212 {
1213  return !StrCaseEqHelper::Compare(val1, val2);
1214 }
1215 
1216 template<typename T1, typename T2>
1217 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ Assertion(
1218  const char* expr1, const char* expr2
1219  , const T1& val1, const T2& val2)
1220 {
1221  if( Compare(val1, val2) )
1222  {
1223  return AssertionSuccess();
1224  }
1225 
1226  return AssertionFailure() << "error: Expected: " << expr1 << " != " << expr2 << " (ignoring case)"
1227  << "\n Actual: " << detail::ShowStringQuoted(FormatForComparisonFailureMessage(val2, val1))
1228  << " vs " << detail::ShowStringQuoted(FormatForComparisonFailureMessage(val1, val2));
1229 }
1230 
1231 } // end of namespace StrCaseNeHelper
1232 
1233 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRCASENE(
1234  const char* expr1, const char* expr2
1235  , const char* val1, const char* val2)
1236 {
1237  return StrCaseNeHelper::Assertion(expr1, expr2, val1, val2);
1238 }
1239 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRCASENE(
1240  const char* expr1, const char* expr2
1241  , const wchar_t* val1, const wchar_t* val2)
1242 {
1243  return StrCaseNeHelper::Assertion(expr1, expr2, val1, val2);
1244 }
1245 template<typename Elem, typename Traits, typename Ax>
1246 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRCASENE(
1247  const char* expr1, const char* expr2
1248  , const ::std::basic_string<Elem, Traits, Ax>& val1
1249  , const ::std::basic_string<Elem, Traits, Ax>& val2)
1250 {
1251  return CmpHelperSTRCASENE(expr1, expr2, val1.c_str(), val2.c_str());
1252 }
1253 template<typename Elem, typename Traits, typename Ax>
1254 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRCASENE(
1255  const char* expr1, const char* expr2
1256  , const Elem* val1
1257  , const ::std::basic_string<Elem, Traits, Ax>& val2)
1258 {
1259  return CmpHelperSTRCASENE(expr1, expr2, val1, val2.c_str());
1260 }
1261 template<typename Elem, typename Traits, typename Ax>
1262 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRCASENE(
1263  const char* expr1, const char* expr2
1264  , const ::std::basic_string<Elem, Traits, Ax>& val1
1265  , const Elem* val2)
1266 {
1267  return CmpHelperSTRCASENE(expr1, expr2, val1.c_str(), val2);
1268 }
1269 
1270 #if defined(IUTEST_OS_WINDOWS)
1271 
1272 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ IsHRESULTSuccess(const char* expr, HRESULT hr)
1273 {
1274  if( SUCCEEDED(hr) )
1275  {
1276  return AssertionSuccess();
1277  }
1278  return AssertionFailure() << "error: Expected: SUCCEEDED(" << expr << ")"
1279  << "\n Actual: " << hr << ": " << detail::win::GetHResultString(hr);
1280 }
1281 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ IsHRESULTFailure(const char* expr, HRESULT hr)
1282 {
1283  if( FAILED(hr) )
1284  {
1285  return AssertionSuccess();
1286  }
1287  return AssertionFailure() << "error: Expected : FAILED(" << expr << ")"
1288  << "\n Actual: " << hr;
1289 }
1290 
1291 #endif
1292 
1293 } // end of namespace internal
1294 
1299 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ FloatLE(
1300  const char* expr1, const char* expr2
1301  , float val1, float val2)
1302 {
1303  return internal::CmpHelperFloatingPointLE<float>(expr1, expr2, val1, val2);
1304 }
1305 
1310 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ DoubleLE(
1311  const char* expr1, const char* expr2
1312  , double val1, double val2)
1313 {
1314  return internal::CmpHelperFloatingPointLE<double>(expr1, expr2, val1, val2);
1315 }
1316 
1317 
1318 } // end of namespace iutest
1319 
1320 #endif // INCG_IRIS_IUTEST_ASSERTION_HPP_E6AF3476_DA81_46F7_A961_ACCEF7363932_
iutest::AssertionReturnType< void >
Assetion Return Type (void)
Definition: iutest_assertion.hpp:159
iutest_result.hpp
iris unit test result
iutest::AssertionReturn
AssertionReturnType< T > AssertionReturn(const T &ret)
Assetion Return 設定
Definition: iutest_assertion.hpp:169
IUTEST_CXX_EXPLICIT_CONVERSION
#define IUTEST_CXX_EXPLICIT_CONVERSION
explicit conversion definition
Definition: iutest_compiler.hpp:636
iutest::TestInfo
テスト情報クラス
Definition: iutest_info.hpp:32
iutest::AssertionReturnType< void >::AssertionReturnType
AssertionReturnType()
コンストラクタ
Definition: iutest_assertion.hpp:162
iutest_config.hpp
iris unit test config
iutest::matchers::A
detail::AnyMatcher< T > A()
Make Any matcher
Definition: iutest_matcher.hpp:2528
iutest::PrintToString
std::string PrintToString(const T &v)
文字列化
Definition: iutest_printers.hpp:678
IUTEST_CXX_NOEXCEPT_SPEC
#define IUTEST_CXX_NOEXCEPT_SPEC
noexcept specification definition
Definition: iutest_compiler.hpp:734
iutest::TestPartResult::Type
Type
結果のタイプ
Definition: iutest_result.hpp:60
iutest
iutest root namespace
Definition: iutest_charcode.hpp:31
iutest_printers.hpp
iris unit test print 出力ヘルパー ファイル
iutest::Message
detail::iuStreamMessage Message
Message クラス
Definition: iutest_assertion.hpp:31
iutest::AssertionResult::Is
static AssertionResult Is(const AssertionResult &ar)
Definition: iutest_assertion.hpp:130
iutest::AssertionResult::operator<<
AssertionResult & operator<<(const T &value)
メッセージ追加
Definition: iutest_assertion.hpp:94
iutest::AssertionResult::Success
static AssertionResult Success()
成功結果の作成
Definition: iutest_assertion.hpp:119
iutest::AssertionReturnType::value
R value
Definition: iutest_assertion.hpp:146
iutest::AssertionResult::Failure
static AssertionResult Failure()
失敗結果の作成
Definition: iutest_assertion.hpp:123
iutest::DoubleLE
AssertionResult IUTEST_ATTRIBUTE_UNUSED_ DoubleLE(const char *expr1, const char *expr2, double val1, double val2)
Double LE Formatter
Definition: iutest_assertion.hpp:1311
iutest::AssertionResult::AssertionResult
AssertionResult(bool result)
コンストラクタ
Definition: iutest_assertion.hpp:61
iutest::AssertionResult
Assertion Result
Definition: iutest_assertion.hpp:54
iutest::TestPartResult::kAssumeFailure
@ kAssumeFailure
前提条件エラー
Definition: iutest_result.hpp:62
iutest::TestPartResult::kSkip
@ kSkip
スキップ
Definition: iutest_result.hpp:63
IUTEST_PP_DISALLOW_MOVE_AND_COPY_AND_ASSIGN
#define IUTEST_PP_DISALLOW_MOVE_AND_COPY_AND_ASSIGN(TypeName)
コピー/ムーブ禁止定義
Definition: iutest_pp.hpp:46
iutest::AssertionReturnType::AssertionReturnType
AssertionReturnType()
コンストラクタ
Definition: iutest_assertion.hpp:148
iutest::GetAssertionResultMessage
const char * GetAssertionResultMessage(const AssertionResult &ar)
テスト結果のメッセージを取得する(for compatible)
Definition: iutest_assertion.hpp:391
iutest::AssertionResult::Is
static AssertionResult Is(const T &b)
成否の取得
Definition: iutest_assertion.hpp:128
iutest_list.hpp
iris unit test list 構造 ファイル
iutest::TestFlag::BREAK_ON_FAILURE
@ BREAK_ON_FAILURE
テスト失敗時にブレーク
Definition: iutest_env.hpp:147
iutest::AssertionReturnType::AssertionReturnType
AssertionReturnType(const R &v)
コンストラクタ
Definition: iutest_assertion.hpp:153
iutest::TestPartResult::kFatalFailure
@ kFatalFailure
致命的な失敗
Definition: iutest_result.hpp:67
iutest::AssertionFailure
AssertionResult AssertionFailure()
テスト失敗を示す AssertionResult オブジェクトの取得
Definition: iutest_assertion.hpp:386
iutest::AssertionResult::AssertionResult
AssertionResult(const AssertionResult &rhs)
コピーコンストラクタ
Definition: iutest_assertion.hpp:63
iutest::AssertionResult::passed
bool passed() const IUTEST_CXX_NOEXCEPT_SPEC
成否
Definition: iutest_assertion.hpp:73
iutest::AssertionResult::failed
bool failed() const IUTEST_CXX_NOEXCEPT_SPEC
成否
Definition: iutest_assertion.hpp:68
iutest::TestFlag::IsEnableFlag
static bool IsEnableFlag(int flag)
フラグが立っているかどうか
Definition: iutest_env.hpp:208
iutest::FloatLE
AssertionResult IUTEST_ATTRIBUTE_UNUSED_ FloatLE(const char *expr1, const char *expr2, float val1, float val2)
Float LE Formatter
Definition: iutest_assertion.hpp:1300
iutest::AssertionResult::message
const char * message() const
メッセージの取得
Definition: iutest_assertion.hpp:78
iutest::TestPartResult
テスト結果を示すクラス
Definition: iutest_result.hpp:54
iutest::AssertionResult::failure_message
const char * failure_message() const
メッセージの取得
Definition: iutest_assertion.hpp:84
iutest::AssertionSuccess
AssertionResult AssertionSuccess()
テスト成功を示す AssertionResult オブジェクトの取得
Definition: iutest_assertion.hpp:382
iutest::AssertionReturnType
Assetion Return Type
Definition: iutest_assertion.hpp:144