15 #ifndef INCG_IRIS_IUTEST_UTIL_ASSERTION_HPP_A45F8265_40E0_44F2_91C6_090B1778657C_
16 #define INCG_IRIS_IUTEST_UTIL_ASSERTION_HPP_A45F8265_40E0_44F2_91C6_090B1778657C_
20 #include "../internal/iutest_type_traits.hpp"
32 #ifndef IUTEST_ASSERT_EQ_COLLECTIONS
33 # define IUTEST_ASSERT_EQ_COLLECTIONS(b1, e1, b2, e2) IUTEST_TEST_EQ_COLLECTIONS(b1, e1, b2, e2, IUTEST_ASSERT_FAILURE)
43 #ifndef IUTEST_EXPECT_EQ_COLLECTIONS
44 # define IUTEST_EXPECT_EQ_COLLECTIONS(b1, e1, b2, e2) IUTEST_TEST_EQ_COLLECTIONS(b1, e1, b2, e2, IUTEST_EXPECT_FAILURE)
54 #ifndef IUTEST_INFORM_EQ_COLLECTIONS
55 # define IUTEST_INFORM_EQ_COLLECTIONS(b1, e1, b2, e2) IUTEST_TEST_EQ_COLLECTIONS(b1, e1, b2, e2, IUTEST_INFORM_FAILURE)
65 #ifndef IUTEST_ASSUME_EQ_COLLECTIONS
66 # define IUTEST_ASSUME_EQ_COLLECTIONS(b1, e1, b2, e2) IUTEST_TEST_EQ_COLLECTIONS(b1, e1, b2, e2, IUTEST_ASSUME_FAILURE)
77 #ifndef IUTEST_ASSERT_NE_COLLECTIONS
78 # define IUTEST_ASSERT_NE_COLLECTIONS(b1, e1, b2, e2) IUTEST_TEST_NE_COLLECTIONS(b1, e1, b2, e2, IUTEST_ASSERT_FAILURE)
88 #ifndef IUTEST_EXPECT_NE_COLLECTIONS
89 # define IUTEST_EXPECT_NE_COLLECTIONS(b1, e1, b2, e2) IUTEST_TEST_NE_COLLECTIONS(b1, e1, b2, e2, IUTEST_EXPECT_FAILURE)
99 #ifndef IUTEST_INFORM_NE_COLLECTIONS
100 # define IUTEST_INFORM_NE_COLLECTIONS(b1, e1, b2, e2) IUTEST_TEST_NE_COLLECTIONS(b1, e1, b2, e2, IUTEST_INFORM_FAILURE)
110 #ifndef IUTEST_ASSUME_NE_COLLECTIONS
111 # define IUTEST_ASSUME_NE_COLLECTIONS(b1, e1, b2, e2) IUTEST_TEST_NE_COLLECTIONS(b1, e1, b2, e2, IUTEST_ASSUME_FAILURE)
120 #ifndef IUTEST_ASSERT_EQ_RANGE
121 # define IUTEST_ASSERT_EQ_RANGE(expected, actual) IUTEST_TEST_EQ_RANGE(expected, actual, IUTEST_ASSERT_FAILURE)
129 #ifndef IUTEST_EXPECT_EQ_RANGE
130 # define IUTEST_EXPECT_EQ_RANGE(expected, actual) IUTEST_TEST_EQ_RANGE(expected, actual, IUTEST_EXPECT_FAILURE)
138 #ifndef IUTEST_INFORM_EQ_RANGE
139 # define IUTEST_INFORM_EQ_RANGE(expected, actual) IUTEST_TEST_EQ_RANGE(expected, actual, IUTEST_INFORM_FAILURE)
147 #ifndef IUTEST_ASSUME_EQ_RANGE
148 # define IUTEST_ASSUME_EQ_RANGE(expected, actual) IUTEST_TEST_EQ_RANGE(expected, actual, IUTEST_ASSUME_FAILURE)
157 #ifndef IUTEST_ASSERT_NE_RANGE
158 # define IUTEST_ASSERT_NE_RANGE(expected, actual) IUTEST_TEST_NE_RANGE(expected, actual, IUTEST_ASSERT_FAILURE)
166 #ifndef IUTEST_EXPECT_NE_RANGE
167 # define IUTEST_EXPECT_NE_RANGE(expected, actual) IUTEST_TEST_NE_RANGE(expected, actual, IUTEST_EXPECT_FAILURE)
175 #ifndef IUTEST_INFORM_NE_RANGE
176 # define IUTEST_INFORM_NE_RANGE(expected, actual) IUTEST_TEST_NE_RANGE(expected, actual, IUTEST_INFORM_FAILURE)
184 #ifndef IUTEST_ASSUME_NE_RANGE
185 # define IUTEST_ASSUME_NE_RANGE(expected, actual) IUTEST_TEST_NE_RANGE(expected, actual, IUTEST_ASSUME_FAILURE)
194 #ifndef IUTEST_ASSERT_STRLNEQ
195 # define IUTEST_ASSERT_STRLNEQ(len, v2) IUTEST_TEST_STRLNEQ(len, v2, IUTEST_ASSERT_FAILURE)
203 #ifndef IUTEST_EXPECT_STRLNEQ
204 # define IUTEST_EXPECT_STRLNEQ(len, v2) IUTEST_TEST_STRLNEQ(len, v2, IUTEST_EXPECT_FAILURE)
212 #ifndef IUTEST_INFORM_STRLNEQ
213 # define IUTEST_INFORM_STRLNEQ(len, v2) IUTEST_TEST_STRLNEQ(len, v2, IUTEST_INFORM_FAILURE)
221 #ifndef IUTEST_ASSUME_STRLNEQ
222 # define IUTEST_ASSUME_STRLNEQ(len, v2) IUTEST_TEST_STRLNEQ(len, v2, IUTEST_ASSUME_FAILURE)
231 #ifndef IUTEST_ASSERT_STRIN
232 # define IUTEST_ASSERT_STRIN(substr, actual) IUTEST_TEST_STRIN(substr, actual, IUTEST_ASSERT_FAILURE)
240 #ifndef IUTEST_EXPECT_STRIN
241 # define IUTEST_EXPECT_STRIN(substr, actual) IUTEST_TEST_STRIN(substr, actual, IUTEST_EXPECT_FAILURE)
249 #ifndef IUTEST_INFORM_STRIN
250 # define IUTEST_INFORM_STRIN(substr, actual) IUTEST_TEST_STRIN(substr, actual, IUTEST_INFORM_FAILURE)
258 #ifndef IUTEST_ASSUME_STRIN
259 # define IUTEST_ASSUME_STRIN(substr, actual) IUTEST_TEST_STRIN(substr, actual, IUTEST_ASSUME_FAILURE)
269 #ifndef IUTEST_ASSERT_STRNOTIN
270 # define IUTEST_ASSERT_STRNOTIN(substr, actual) IUTEST_TEST_STRNOTIN(substr, actual, IUTEST_ASSERT_FAILURE)
278 #ifndef IUTEST_EXPECT_STRNOTIN
279 # define IUTEST_EXPECT_STRNOTIN(substr, actual) IUTEST_TEST_STRNOTIN(substr, actual, IUTEST_EXPECT_FAILURE)
287 #ifndef IUTEST_INFORM_STRNOTIN
288 # define IUTEST_INFORM_STRNOTIN(substr, actual) IUTEST_TEST_STRNOTIN(substr, actual, IUTEST_INFORM_FAILURE)
296 #ifndef IUTEST_ASSUME_STRNOTIN
297 # define IUTEST_ASSUME_STRNOTIN(substr, actual) IUTEST_TEST_STRNOTIN(substr, actual, IUTEST_ASSUME_FAILURE)
306 #ifndef IUTEST_ASSERT_NAN
307 # define IUTEST_ASSERT_NAN(actual) IUTEST_TEST_NAN(actual, IUTEST_ASSERT_FAILURE)
314 #ifndef IUTEST_EXPECT_NAN
315 # define IUTEST_EXPECT_NAN(actual) IUTEST_TEST_NAN(actual, IUTEST_EXPECT_FAILURE)
322 #ifndef IUTEST_INFORM_NAN
323 # define IUTEST_INFORM_NAN(actual) IUTEST_TEST_NAN(actual, IUTEST_INFORM_FAILURE)
330 #ifndef IUTEST_ASSUME_NAN
331 # define IUTEST_ASSUME_NAN(actual) IUTEST_TEST_NAN(actual, IUTEST_ASSUME_FAILURE)
342 #ifndef IUTEST_ASSERT_MATCHES_REGEXEQ
343 # define IUTEST_ASSERT_MATCHES_REGEXEQ(regex_str, actual) \
344 IUTEST_TEST_MATCHES_REGEXEQ(regex_str, actual, IUTEST_ASSERT_FAILURE)
352 #ifndef IUTEST_EXPECT_MATCHES_REGEXEQ
353 # define IUTEST_EXPECT_MATCHES_REGEXEQ(regex_str, actual) \
354 IUTEST_TEST_MATCHES_REGEXEQ(regex_str, actual, IUTEST_EXPECT_FAILURE)
362 #ifndef IUTEST_INFORM_MATCHES_REGEXEQ
363 # define IUTEST_INFORM_MATCHES_REGEXEQ(regex_str, actual) \
364 IUTEST_TEST_MATCHES_REGEXEQ(regex_str, actual, IUTEST_INFORM_FAILURE)
372 #ifndef IUTEST_ASSUME_MATCHES_REGEXEQ
373 # define IUTEST_ASSUME_MATCHES_REGEXEQ(regex_str, actual) \
374 IUTEST_TEST_MATCHES_REGEXEQ(regex_str, actual, IUTEST_ASSUME_FAILURE)
383 #ifndef IUTEST_ASSERT_MATCHES_REGEXNE
384 # define IUTEST_ASSERT_MATCHES_REGEXNE(regex_str, actual) \
385 IUTEST_TEST_MATCHES_REGEXNE(regex_str, actual, IUTEST_ASSERT_FAILURE)
393 #ifndef IUTEST_EXPECT_MATCHES_REGEXNE
394 # define IUTEST_EXPECT_MATCHES_REGEXNE(regex_str, actual) \
395 IUTEST_TEST_MATCHES_REGEXNE(regex_str, actual, IUTEST_EXPECT_FAILURE)
403 #ifndef IUTEST_INFORM_MATCHES_REGEXNE
404 # define IUTEST_INFORM_MATCHES_REGEXNE(regex_str, actual) \
405 IUTEST_TEST_MATCHES_REGEXNE(regex_str, actual, IUTEST_INFORM_FAILURE)
413 #ifndef IUTEST_ASSUME_MATCHES_REGEXNE
414 # define IUTEST_ASSUME_MATCHES_REGEXNE(regex_str, actual) \
415 IUTEST_TEST_MATCHES_REGEXNE(regex_str, actual, IUTEST_ASSUME_FAILURE)
426 #ifndef IUTEST_ASSERT_CONTAINS_REGEXEQ
427 # define IUTEST_ASSERT_CONTAINS_REGEXEQ(regex_str, actual) \
428 IUTEST_TEST_CONTAINS_REGEXEQ(regex_str, actual, IUTEST_ASSERT_FAILURE)
436 #ifndef IUTEST_EXPECT_CONTAINS_REGEXEQ
437 # define IUTEST_EXPECT_CONTAINS_REGEXEQ(regex_str, actual) \
438 IUTEST_TEST_CONTAINS_REGEXEQ(regex_str, actual, IUTEST_EXPECT_FAILURE)
446 #ifndef IUTEST_INFORM_CONTAINS_REGEXEQ
447 # define IUTEST_INFORM_CONTAINS_REGEXEQ(regex_str, actual) \
448 IUTEST_TEST_CONTAINS_REGEXEQ(regex_str, actual, IUTEST_INFORM_FAILURE)
456 #ifndef IUTEST_ASSUME_CONTAINS_REGEXEQ
457 # define IUTEST_ASSUME_CONTAINS_REGEXEQ(regex_str, actual) \
458 IUTEST_TEST_CONTAINS_REGEXEQ(regex_str, actual, IUTEST_ASSUME_FAILURE)
467 #ifndef IUTEST_ASSERT_CONTAINS_REGEXNE
468 # define IUTEST_ASSERT_CONTAINS_REGEXNE(regex_str, actual) \
469 IUTEST_TEST_CONTAINS_REGEXNE(regex_str, actual, IUTEST_ASSERT_FAILURE)
477 #ifndef IUTEST_EXPECT_CONTAINS_REGEXNE
478 # define IUTEST_EXPECT_CONTAINS_REGEXNE(regex_str, actual) \
479 IUTEST_TEST_CONTAINS_REGEXNE(regex_str, actual, IUTEST_EXPECT_FAILURE)
487 #ifndef IUTEST_INFORM_CONTAINS_REGEXNE
488 # define IUTEST_INFORM_CONTAINS_REGEXNE(regex_str, actual) \
489 IUTEST_TEST_CONTAINS_REGEXNE(regex_str, actual, IUTEST_INFORM_FAILURE)
497 #ifndef IUTEST_ASSUME_CONTAINS_REGEXNE
498 # define IUTEST_ASSUME_CONTAINS_REGEXNE(regex_str, actual) \
499 IUTEST_TEST_CONTAINS_REGEXNE(regex_str, actual, IUTEST_ASSUME_FAILURE)
510 #ifndef IUTEST_NO_UTIL_ASSERTION_GTEST_COMPATIBLE
512 #define ASSERT_EQ_COLLECTIONS IUTEST_ASSERT_EQ_COLLECTIONS
513 #define ASSERT_NE_COLLECTIONS IUTEST_ASSERT_NE_COLLECTIONS
514 #define ASSERT_EQ_RANGE IUTEST_ASSERT_EQ_RANGE
515 #define ASSERT_NE_RANGE IUTEST_ASSERT_NE_RANGE
516 #define ASSERT_STRLNEQ IUTEST_ASSERT_STRLNEQ
517 #define ASSERT_STRIN IUTEST_ASSERT_STRIN
518 #define ASSERT_STRNOTIN IUTEST_ASSERT_STRNOTIN
519 #define ASSERT_BAB IUTEST_ASSERT_NAN
521 #define EXPECT_EQ_COLLECTIONS IUTEST_EXPECT_EQ_COLLECTIONS
522 #define EXPECT_NE_COLLECTIONS IUTEST_EXPECT_NE_COLLECTIONS
523 #define EXPECT_EQ_RANGE IUTEST_EXPECT_EQ_RANGE
524 #define EXPECT_NE_RANGE IUTEST_EXPECT_NE_RANGE
525 #define EXPECT_STRLNEQ IUTEST_EXPECT_STRLNEQ
526 #define EXPECT_STRIN IUTEST_EXPECT_STRIN
527 #define EXPECT_STRNOTIN IUTEST_EXPECT_STRNOTIN
528 #define EXPECT_NAN IUTEST_EXPECT_NAN
530 #define INFORM_EQ_COLLECTIONS IUTEST_INFORM_EQ_COLLECTIONS
531 #define INFORM_NE_COLLECTIONS IUTEST_INFORM_NE_COLLECTIONS
532 #define INFORM_EQ_RANGE IUTEST_INFORM_EQ_RANGE
533 #define INFORM_NE_RANGE IUTEST_INFORM_NE_RANGE
534 #define INFORM_STRLNEQ IUTEST_INFORM_STRLNEQ
535 #define INFORM_STRIN IUTEST_INFORM_STRIN
536 #define INFORM_STRNOTIN IUTEST_INFORM_STRNOTIN
537 #define INFORM_NAN IUTEST_INFORM_NAN
539 #define ASSUME_EQ_COLLECTIONS IUTEST_ASSUME_EQ_COLLECTIONS
540 #define ASSUME_NE_COLLECTIONS IUTEST_ASSUME_NE_COLLECTIONS
541 #define ASSUME_EQ_RANGE IUTEST_ASSUME_EQ_RANGE
542 #define ASSUME_NE_RANGE IUTEST_ASSUME_NE_RANGE
543 #define ASSUME_STRLNEQ IUTEST_ASSUME_STRLNEQ
544 #define ASSUME_STRIN IUTEST_ASSUME_STRIN
545 #define ASSUME_STRNOTIN IUTEST_ASSUME_STRNOTIN
546 #define ASSUME_NAN IUTEST_ASSUME_NAN
550 #define ASSERT_MATCHES_REGEXEQ IUTEST_ASSERT_MATCHES_REGEXEQ
551 #define EXPECT_MATCHES_REGEXEQ IUTEST_EXPECT_MATCHES_REGEXEQ
552 #define INFORM_MATCHES_REGEXEQ IUTEST_INFORM_MATCHES_REGEXEQ
553 #define ASSUME_MATCHES_REGEXEQ IUTEST_ASSUME_MATCHES_REGEXEQ
555 #define ASSERT_MATCHES_REGEXNE IUTEST_ASSERT_MATCHES_REGEXNE
556 #define EXPECT_MATCHES_REGEXNE IUTEST_EXPECT_MATCHES_REGEXNE
557 #define INFORM_MATCHES_REGEXNE IUTEST_INFORM_MATCHES_REGEXNE
558 #define ASSUME_MATCHES_REGEXNE IUTEST_ASSUME_MATCHES_REGEXNE
560 #define ASSERT_CONTAINS_REGEXEQ IUTEST_ASSERT_CONTAINS_REGEXEQ
561 #define EXPECT_CONTAINS_REGEXEQ IUTEST_EXPECT_CONTAINS_REGEXEQ
562 #define INFORM_CONTAINS_REGEXEQ IUTEST_INFORM_CONTAINS_REGEXEQ
563 #define ASSUME_CONTAINS_REGEXEQ IUTEST_ASSUME_CONTAINS_REGEXEQ
565 #define ASSERT_CONTAINS_REGEXNE IUTEST_ASSERT_CONTAINS_REGEXNE
566 #define EXPECT_CONTAINS_REGEXNE IUTEST_EXPECT_CONTAINS_REGEXNE
567 #define INFORM_CONTAINS_REGEXNE IUTEST_INFORM_CONTAINS_REGEXNE
568 #define ASSUME_CONTAINS_REGEXNE IUTEST_ASSUME_CONTAINS_REGEXNE
582 #define IUTEST_TEST_EQ_COLLECTIONS(b1, e1, b2, e2, on_failure) IUTEST_PRED_FORMAT4_( ::iuutil::CmpHelperEqCollections, b1, e1, b2, e2, on_failure)
583 #define IUTEST_TEST_NE_COLLECTIONS(b1, e1, b2, e2, on_failure) IUTEST_PRED_FORMAT4_( ::iuutil::CmpHelperNeCollections, b1, e1, b2, e2, on_failure)
584 #define IUTEST_TEST_EQ_RANGE(expected, actual, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperEqRange, expected, actual, on_failure)
585 #define IUTEST_TEST_NE_RANGE(expected, actual, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperNeRange, expected, actual, on_failure)
587 #define IUTEST_TEST_STRLNEQ(len, v2, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperSTRLNEQ, len, v2, on_failure )
588 #define IUTEST_TEST_STRIN(substr, actual, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperSTRIN, substr, actual, on_failure )
589 #define IUTEST_TEST_STRNOTIN(substr, actual, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperSTRNOTIN, substr, actual, on_failure )
591 #define IUTEST_TEST_NAN(actual, on_failure) IUTEST_PRED_FORMAT1_( ::iuutil::CmpHelperIsNan, actual, on_failure )
595 #define IUTEST_TEST_MATCHES_REGEXEQ(regex, actual, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperMatchesRegexEq, regex, actual, on_failure )
596 #define IUTEST_TEST_MATCHES_REGEXNE(regex, actual, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperMatchesRegexNe, regex, actual, on_failure )
598 #define IUTEST_TEST_CONTAINS_REGEXEQ(regex, actual, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperContainsRegexEq, regex, actual, on_failure )
599 #define IUTEST_TEST_CONTAINS_REGEXNE(regex, actual, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperContainsRegexNe, regex, actual, on_failure )
615 template<
typename T1,
typename T2>
621 for(elem=0; b1 != e1 && b2 != e2; ++b1, ++b2, ++elem)
623 if(!::iutest::internal::backward::EqHelper<false>::Compare(
"",
"", *b1, *b2))
626 ar <<
"\nMismatch in a position " << elem <<
": "
627 << ::iutest::internal::FormatForComparisonFailureMessage(*b1, *b2)
628 <<
" vs " << ::iutest::internal::FormatForComparisonFailureMessage(*b2, *b1);
634 for(; b1 != e1; ++b1, ++elem1) {}
636 ar <<
"\nMismatch element : " << elem1 <<
" vs " << elem;
641 for(; b2 != e2; ++b2, ++elem2) {}
643 ar <<
"\nMismatch element : " << elem <<
" vs " << elem2;
652 template<
typename T1,
typename T2>
658 for(elem=0; b1 != e1 && b2 != e2; ++b1, ++b2, ++elem)
660 if(!::iutest::internal::backward::NeHelper<false>::Compare(
"",
"", *b1, *b2))
662 ar << ::iutest::internal::FormatForComparisonFailureMessage(*b1, *b2);
669 if( (b1 != e1) || (b2 != e2) )
684 template<
typename T1,
typename T2>
686 ,
const char* expr2b,
const char* expr2e
687 , T1 b1, T1 e1, T2 b2, T2 e2)
703 template<
typename T1,
typename T2>
705 ,
const char* expr2b,
const char* expr2e
706 , T1 b1, T1 e1, T2 b2, T2 e2)
722 template<
typename T1,
typename T2>
724 , T1 b1, T1 e1, T2 b2, T2 e2)
742 template<
typename T1,
typename T2>
744 ,
const T1& expected,
const T2& actual)
748 , begin(actual), end(actual));
754 template<
typename T1,
typename T2>
756 ,
const T1& expected,
const T2& actual)
760 CmpHelperNeIterator(begin(expected), end(expected), begin(actual), end(actual)))
767 <<
" \n Actual:" << ::iutest::internal::FormatForComparisonFailureMessage(expected, actual);
774 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_
CmpHelperSTRLNEQ(
const char* expr1,
const char* expr2
775 ,
size_t len1,
const char* val2)
777 const size_t len2 = strlen(val2);
783 <<
"\n Actual: " << val2 <<
" : " << len2 <<
"\nExpected: " << len1;
788 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_
CmpHelperSTRLNEQ(
const char* expr1,
const char* expr2
789 ,
size_t len1, const ::std::string& val2)
791 const size_t len2 = val2.length();
797 <<
"\n Actual: " << val2 <<
" : " << len2 <<
"\nExpected: " << len1;
802 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_
CmpHelperSTRLNEQ(
const char* expr1,
const char* expr2
803 ,
size_t len1,
const wchar_t* val2)
805 const size_t len2 = wcslen(val2);
811 <<
"\n Actual: " << val2 <<
" : " << len2 <<
"\nExpected: " << len1;
814 namespace StrInHelper
817 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(
const char* substr,
const char* actual)
819 if( substr == NULL || actual == NULL )
821 return substr == actual;
823 return strstr(actual, substr) != NULL;
826 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(
const wchar_t* substr,
const wchar_t* actual)
828 if( substr == NULL || actual == NULL )
830 return substr == actual;
832 return wcsstr(actual, substr) != NULL;
835 template<
typename Elem,
typename Traits,
typename Ax>
836 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const ::std::basic_string<Elem, Traits, Ax>& substr
837 , const ::std::basic_string<Elem, Traits, Ax>& actual)
839 return Compare(substr.c_str(), actual.c_str());
841 template<
typename Elem,
typename Traits,
typename Ax>
842 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(
const Elem* substr
843 , const ::std::basic_string<Elem, Traits, Ax>& actual)
845 return Compare(substr, actual.c_str());
847 template<
typename Elem,
typename Traits,
typename Ax>
848 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const ::std::basic_string<Elem, Traits, Ax>& substr
849 ,
const Elem* actual)
851 return Compare(substr.c_str(), actual);
854 template<
typename T1,
typename T2>
855 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ Assertion(
const char* substr_str,
const char* actual_str
856 ,
const T1& substr,
const T2& actual)
858 if( Compare(substr, actual) )
864 <<
"\n Actual: " <<
"strstr(\"" << actual <<
"\", " << substr <<
") == NULL";
872 template<
typename T1,
typename T2>
873 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_
CmpHelperSTRIN(
const char* substr_str,
const char* actual_str
874 ,
const T1& substr,
const T2& actual)
876 return StrInHelper::Assertion(substr_str, actual_str, substr, actual);
879 namespace StrNotInHelper
882 template<
typename T1,
typename T2>
883 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(
const T1& substr,
const T2& actual)
885 return !StrInHelper::Compare(substr, actual);
888 template<
typename T1,
typename T2>
889 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ Assertion(
const char* substr_str,
const char* actual_str
890 ,
const T1& substr,
const T2& actual)
892 if( Compare(substr, actual) )
898 <<
"\n Actual: " <<
"strstr(\"" << actual <<
"\", " << substr <<
") != NULL";
906 template<
typename T1,
typename T2>
907 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_
CmpHelperSTRNOTIN(
const char* substr_str,
const char* actual_str
908 ,
const T1& substr,
const T2& actual)
910 return StrNotInHelper::Assertion(substr_str, actual_str, substr, actual);
913 namespace floationg_point_helper
917 ::iutest::internal::FloatingPoint<float> CastToFloatingPoint(
const T& x)
919 return ::iutest::internal::FloatingPoint<float>(
static_cast<float>(x));
921 inline ::iutest::internal::FloatingPoint<double> CastToFloatingPoint(
const double& x)
923 return ::iutest::internal::FloatingPoint<double>(x);
932 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_
CmpHelperIsNan(
const char* actual_str,
const T& actual)
934 if( floationg_point_helper::CastToFloatingPoint(actual).is_nan() )
939 <<
"\n Actual: " << actual <<
"\nExpected: NaN";
944 namespace RegexHelper
947 inline bool FullMatch(const ::std::string& str, const ::iutest::internal::RE& re)
949 return ::iutest::internal::RE::FullMatch(str, re);
951 inline bool FullMatch(
const char* str, const ::iutest::internal::RE& re)
957 return ::iutest::internal::RE::FullMatch(str, re);
960 inline bool PartialMatch(const ::std::string& str, const ::iutest::internal::RE& re)
962 return ::iutest::internal::RE::PartialMatch(str, re);
964 inline bool PartialMatch(
const char* str, const ::iutest::internal::RE& re)
970 return ::iutest::internal::RE::PartialMatch(str, re);
975 namespace MatchesRegexEqHelper
978 template<
typename T1,
typename T2>
979 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(
const T1& regex,
const T2& actual)
981 ::iutest::internal::RE iure(regex);
982 return RegexHelper::FullMatch(actual, iure);
985 template<
typename T1,
typename T2>
986 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ Assertion(
const char* regex_str,
const char* actual_str
987 ,
const T1& regex,
const T2& actual)
989 if( Compare(regex, actual) )
993 ::std::string expected_str =
"Matches Regex (";
994 expected_str += regex_str;
997 return ::iutest::internal::EqFailure(expected_str.c_str(), actual_str
1008 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperMatchesRegexEq(
const char* regex_str,
const char* actual_str
1009 ,
const char* regex,
const char* actual)
1011 return MatchesRegexEqHelper::Assertion(regex_str, actual_str, regex, actual);
1014 namespace MatchesRegexNeHelper
1017 template<
typename T1,
typename T2>
1018 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ Assertion(
const char* regex_str,
const char* actual_str
1019 ,
const T1& regex,
const T2& actual)
1021 if( !MatchesRegexEqHelper::Compare(regex, actual) )
1025 ::std::string expected_str =
"Not Matches Regex (";
1026 expected_str += regex_str;
1027 expected_str +=
")";
1029 return ::iutest::internal::EqFailure(expected_str.c_str(), actual_str
1040 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperMatchesRegexNe(
const char* regex_str,
const char* actual_str
1041 ,
const char* regex,
const char* actual)
1043 return MatchesRegexNeHelper::Assertion(regex_str, actual_str, regex, actual);
1046 namespace ContainsRegexEqHelper
1049 template<
typename T1,
typename T2>
1050 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(
const T1& regex,
const T2& actual)
1052 ::iutest::internal::RE m(regex);
1053 return RegexHelper::PartialMatch(actual, m);
1056 template<
typename T1,
typename T2>
1057 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ Assertion(
const char* regex_str,
const char* actual_str
1058 ,
const T1& regex,
const T2& actual)
1060 if( Compare(regex, actual) )
1064 ::std::string expected_str =
"Contains Regex (";
1065 expected_str += regex_str;
1066 expected_str +=
")";
1068 return ::iutest::internal::EqFailure(expected_str.c_str(), actual_str
1079 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperContainsRegexEq(
const char* regex_str,
const char* actual_str
1080 ,
const char* regex,
const char* actual)
1082 return ContainsRegexEqHelper::Assertion(regex_str, actual_str, regex, actual);
1085 namespace ContainsRegexNeHelper
1088 template<
typename T1,
typename T2>
1089 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ Assertion(
const char* regex_str,
const char* actual_str
1090 ,
const T1& regex,
const T2& actual)
1092 if( !ContainsRegexEqHelper::Compare(regex, actual) )
1096 ::std::string expected_str =
"Not Contains Regex (";
1097 expected_str += regex_str;
1098 expected_str +=
")";
1100 return ::iutest::internal::EqFailure(expected_str.c_str(), actual_str
1111 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperContainsRegexNe(
const char* regex_str,
const char* actual_str
1112 ,
const char* regex,
const char* actual)
1114 return ContainsRegexNeHelper::Assertion(regex_str, actual_str, regex, actual);
Assertion Result
Definition: iutest_assertion.hpp:67
#define IUTEST_USING_BEGIN_END()
using begin,end
Definition: iutest_stdlib.hpp:34
AssertionResult AssertionSuccess()
テスト成功を示す AssertionResult オブジェクトの取得
Definition: iutest_assertion.hpp:406
std::string PrintToString(const T &v)
文字列化
Definition: iutest_printers.hpp:767
AssertionResult AssertionFailure()
テスト失敗を示す AssertionResult オブジェクトの取得
Definition: iutest_assertion.hpp:410
detail::iuStreamMessage Message
Message クラス
Definition: iutest_assertion.hpp:33
const char * GetAssertionResultMessage(const AssertionResult &ar)
テスト結果のメッセージを取得する(for compatible)
Definition: iutest_assertion.hpp:415
iutest utility namespace
Definition: iutest_util.hpp:36
inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRIN(const char *substr_str, const char *actual_str, const T1 &substr, const T2 &actual)
文字列部分一致アサーションフォーマッター
Definition: iutest_util_assertion.hpp:874
inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRLNEQ(const char *expr1, const char *expr2, size_t len1, const char *val2)
文字列長アサーションフォーマッター
Definition: iutest_util_assertion.hpp:775
::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperEqRange(const char *expected_expr, const char *actual_expr, const T1 &expected, const T2 &actual)
Equal Range Helper
Definition: iutest_util_assertion.hpp:744
::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperNeCollections(const char *expr1b, const char *expr1e, const char *expr2b, const char *expr2e, T1 b1, T1 e1, T2 b2, T2 e2)
Equal Collection Helper
Definition: iutest_util_assertion.hpp:705
::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperEqCollections(const char *expr1b, const char *expr1e, const char *expr2b, const char *expr2e, T1 b1, T1 e1, T2 b2, T2 e2)
Equal Collection Helper
Definition: iutest_util_assertion.hpp:686
inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperIsNan(const char *actual_str, const T &actual)
NaN Assertion formatter
Definition: iutest_util_assertion.hpp:933
::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperNeRange(const char *expected_expr, const char *actual_expr, const T1 &expected, const T2 &actual)
Not Equal Range Helper
Definition: iutest_util_assertion.hpp:756
::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperEqIterator(T1 b1, T1 e1, T2 b2, T2 e2)
Equal Collection Helper
Definition: iutest_util_assertion.hpp:617
inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRNOTIN(const char *substr_str, const char *actual_str, const T1 &substr, const T2 &actual)
文字列部分一致アサーションフォーマッター
Definition: iutest_util_assertion.hpp:908