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)
308 #ifndef IUTEST_ASSERT_MATCHES_REGEXEQ
309 # define IUTEST_ASSERT_MATCHES_REGEXEQ(regex_str, actual) \
310 IUTEST_TEST_MATCHES_REGEXEQ(regex_str, actual, IUTEST_ASSERT_FAILURE)
318 #ifndef IUTEST_EXPECT_MATCHES_REGEXEQ
319 # define IUTEST_EXPECT_MATCHES_REGEXEQ(regex_str, actual) \
320 IUTEST_TEST_MATCHES_REGEXEQ(regex_str, actual, IUTEST_EXPECT_FAILURE)
328 #ifndef IUTEST_INFORM_MATCHES_REGEXEQ
329 # define IUTEST_INFORM_MATCHES_REGEXEQ(regex_str, actual) \
330 IUTEST_TEST_MATCHES_REGEXEQ(regex_str, actual, IUTEST_INFORM_FAILURE)
338 #ifndef IUTEST_ASSUME_MATCHES_REGEXEQ
339 # define IUTEST_ASSUME_MATCHES_REGEXEQ(regex_str, actual) \
340 IUTEST_TEST_MATCHES_REGEXEQ(regex_str, actual, IUTEST_ASSUME_FAILURE)
349 #ifndef IUTEST_ASSERT_MATCHES_REGEXNE
350 # define IUTEST_ASSERT_MATCHES_REGEXNE(regex_str, actual) \
351 IUTEST_TEST_MATCHES_REGEXNE(regex_str, actual, IUTEST_ASSERT_FAILURE)
359 #ifndef IUTEST_EXPECT_MATCHES_REGEXNE
360 # define IUTEST_EXPECT_MATCHES_REGEXNE(regex_str, actual) \
361 IUTEST_TEST_MATCHES_REGEXNE(regex_str, actual, IUTEST_EXPECT_FAILURE)
369 #ifndef IUTEST_INFORM_MATCHES_REGEXNE
370 # define IUTEST_INFORM_MATCHES_REGEXNE(regex_str, actual) \
371 IUTEST_TEST_MATCHES_REGEXNE(regex_str, actual, IUTEST_INFORM_FAILURE)
379 #ifndef IUTEST_ASSUME_MATCHES_REGEXNE
380 # define IUTEST_ASSUME_MATCHES_REGEXNE(regex_str, actual) \
381 IUTEST_TEST_MATCHES_REGEXNE(regex_str, actual, IUTEST_ASSUME_FAILURE)
392 #ifndef IUTEST_ASSERT_CONTAINS_REGEXEQ
393 # define IUTEST_ASSERT_CONTAINS_REGEXEQ(regex_str, actual) \
394 IUTEST_TEST_CONTAINS_REGEXEQ(regex_str, actual, IUTEST_ASSERT_FAILURE)
402 #ifndef IUTEST_EXPECT_CONTAINS_REGEXEQ
403 # define IUTEST_EXPECT_CONTAINS_REGEXEQ(regex_str, actual) \
404 IUTEST_TEST_CONTAINS_REGEXEQ(regex_str, actual, IUTEST_EXPECT_FAILURE)
412 #ifndef IUTEST_INFORM_CONTAINS_REGEXEQ
413 # define IUTEST_INFORM_CONTAINS_REGEXEQ(regex_str, actual) \
414 IUTEST_TEST_CONTAINS_REGEXEQ(regex_str, actual, IUTEST_INFORM_FAILURE)
422 #ifndef IUTEST_ASSUME_CONTAINS_REGEXEQ
423 # define IUTEST_ASSUME_CONTAINS_REGEXEQ(regex_str, actual) \
424 IUTEST_TEST_CONTAINS_REGEXEQ(regex_str, actual, IUTEST_ASSUME_FAILURE)
433 #ifndef IUTEST_ASSERT_CONTAINS_REGEXNE
434 # define IUTEST_ASSERT_CONTAINS_REGEXNE(regex_str, actual) \
435 IUTEST_TEST_CONTAINS_REGEXNE(regex_str, actual, IUTEST_ASSERT_FAILURE)
443 #ifndef IUTEST_EXPECT_CONTAINS_REGEXNE
444 # define IUTEST_EXPECT_CONTAINS_REGEXNE(regex_str, actual) \
445 IUTEST_TEST_CONTAINS_REGEXNE(regex_str, actual, IUTEST_EXPECT_FAILURE)
453 #ifndef IUTEST_INFORM_CONTAINS_REGEXNE
454 # define IUTEST_INFORM_CONTAINS_REGEXNE(regex_str, actual) \
455 IUTEST_TEST_CONTAINS_REGEXNE(regex_str, actual, IUTEST_INFORM_FAILURE)
463 #ifndef IUTEST_ASSUME_CONTAINS_REGEXNE
464 # define IUTEST_ASSUME_CONTAINS_REGEXNE(regex_str, actual) \
465 IUTEST_TEST_CONTAINS_REGEXNE(regex_str, actual, IUTEST_ASSUME_FAILURE)
476 #ifndef IUTEST_NO_UTIL_ASSERTION_GTEST_COMPATIBLE
478 #define ASSERT_EQ_COLLECTIONS IUTEST_ASSERT_EQ_COLLECTIONS
479 #define ASSERT_NE_COLLECTIONS IUTEST_ASSERT_NE_COLLECTIONS
480 #define ASSERT_EQ_RANGE IUTEST_ASSERT_EQ_RANGE
481 #define ASSERT_NE_RANGE IUTEST_ASSERT_NE_RANGE
482 #define ASSERT_STRLNEQ IUTEST_ASSERT_STRLNEQ
483 #define ASSERT_STRIN IUTEST_ASSERT_STRIN
484 #define ASSERT_STRNOTIN IUTEST_ASSERT_STRNOTIN
486 #define EXPECT_EQ_COLLECTIONS IUTEST_EXPECT_EQ_COLLECTIONS
487 #define EXPECT_NE_COLLECTIONS IUTEST_EXPECT_NE_COLLECTIONS
488 #define EXPECT_EQ_RANGE IUTEST_EXPECT_EQ_RANGE
489 #define EXPECT_NE_RANGE IUTEST_EXPECT_NE_RANGE
490 #define EXPECT_STRLNEQ IUTEST_EXPECT_STRLNEQ
491 #define EXPECT_STRIN IUTEST_EXPECT_STRIN
492 #define EXPECT_STRNOTIN IUTEST_EXPECT_STRNOTIN
494 #define INFORM_EQ_COLLECTIONS IUTEST_INFORM_EQ_COLLECTIONS
495 #define INFORM_NE_COLLECTIONS IUTEST_INFORM_NE_COLLECTIONS
496 #define INFORM_EQ_RANGE IUTEST_INFORM_EQ_RANGE
497 #define INFORM_NE_RANGE IUTEST_INFORM_NE_RANGE
498 #define INFORM_STRLNEQ IUTEST_INFORM_STRLNEQ
499 #define INFORM_STRIN IUTEST_INFORM_STRIN
500 #define INFORM_STRNOTIN IUTEST_INFORM_STRNOTIN
502 #define ASSUME_EQ_COLLECTIONS IUTEST_ASSUME_EQ_COLLECTIONS
503 #define ASSUME_NE_COLLECTIONS IUTEST_ASSUME_NE_COLLECTIONS
504 #define ASSUME_EQ_RANGE IUTEST_ASSUME_EQ_RANGE
505 #define ASSUME_NE_RANGE IUTEST_ASSUME_NE_RANGE
506 #define ASSUME_STRLNEQ IUTEST_ASSUME_STRLNEQ
507 #define ASSUME_STRIN IUTEST_ASSUME_STRIN
508 #define ASSUME_STRNOTIN IUTEST_ASSUME_STRNOTIN
512 #define ASSERT_MATCHES_REGEXEQ IUTEST_ASSERT_MATCHES_REGEXEQ
513 #define EXPECT_MATCHES_REGEXEQ IUTEST_EXPECT_MATCHES_REGEXEQ
514 #define INFORM_MATCHES_REGEXEQ IUTEST_INFORM_MATCHES_REGEXEQ
515 #define ASSUME_MATCHES_REGEXEQ IUTEST_ASSUME_MATCHES_REGEXEQ
517 #define ASSERT_MATCHES_REGEXNE IUTEST_ASSERT_MATCHES_REGEXNE
518 #define EXPECT_MATCHES_REGEXNE IUTEST_EXPECT_MATCHES_REGEXNE
519 #define INFORM_MATCHES_REGEXNE IUTEST_INFORM_MATCHES_REGEXNE
520 #define ASSUME_MATCHES_REGEXNE IUTEST_ASSUME_MATCHES_REGEXNE
522 #define ASSERT_CONTAINS_REGEXEQ IUTEST_ASSERT_CONTAINS_REGEXEQ
523 #define EXPECT_CONTAINS_REGEXEQ IUTEST_EXPECT_CONTAINS_REGEXEQ
524 #define INFORM_CONTAINS_REGEXEQ IUTEST_INFORM_CONTAINS_REGEXEQ
525 #define ASSUME_CONTAINS_REGEXEQ IUTEST_ASSUME_CONTAINS_REGEXEQ
527 #define ASSERT_CONTAINS_REGEXNE IUTEST_ASSERT_CONTAINS_REGEXNE
528 #define EXPECT_CONTAINS_REGEXNE IUTEST_EXPECT_CONTAINS_REGEXNE
529 #define INFORM_CONTAINS_REGEXNE IUTEST_INFORM_CONTAINS_REGEXNE
530 #define ASSUME_CONTAINS_REGEXNE IUTEST_ASSUME_CONTAINS_REGEXNE
544 #define IUTEST_TEST_EQ_COLLECTIONS(b1, e1, b2, e2, on_failure) IUTEST_PRED_FORMAT4_( ::iuutil::CmpHelperEqCollections, b1, e1, b2, e2, on_failure)
545 #define IUTEST_TEST_NE_COLLECTIONS(b1, e1, b2, e2, on_failure) IUTEST_PRED_FORMAT4_( ::iuutil::CmpHelperNeCollections, b1, e1, b2, e2, on_failure)
546 #define IUTEST_TEST_EQ_RANGE(expected, actual, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperEqRange, expected, actual, on_failure)
547 #define IUTEST_TEST_NE_RANGE(expected, actual, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperNeRange, expected, actual, on_failure)
549 #define IUTEST_TEST_STRLNEQ(len, v2, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperSTRLNEQ, len, v2, on_failure )
550 #define IUTEST_TEST_STRIN(substr, actual, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperSTRIN, substr, actual, on_failure )
551 #define IUTEST_TEST_STRNOTIN(substr, actual, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperSTRNOTIN, substr, actual, on_failure )
555 #define IUTEST_TEST_MATCHES_REGEXEQ(regex, actual, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperMatchesRegexEq, regex, actual, on_failure )
556 #define IUTEST_TEST_MATCHES_REGEXNE(regex, actual, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperMatchesRegexNe, regex, actual, on_failure )
558 #define IUTEST_TEST_CONTAINS_REGEXEQ(regex, actual, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperContainsRegexEq, regex, actual, on_failure )
559 #define IUTEST_TEST_CONTAINS_REGEXNE(regex, actual, on_failure) IUTEST_PRED_FORMAT2_( ::iuutil::CmpHelperContainsRegexNe, regex, actual, on_failure )
575 template<
typename T1,
typename T2>
581 for(elem=0; b1 != e1 && b2 != e2; ++b1, ++b2, ++elem)
583 if(!::iutest::internal::backward::EqHelper<false>::Compare(
"",
"", *b1, *b2))
586 ar <<
"\nMismatch in a position " << elem <<
": "
587 << ::iutest::internal::FormatForComparisonFailureMessage(*b1, *b2)
588 <<
" vs " << ::iutest::internal::FormatForComparisonFailureMessage(*b2, *b1);
594 for(; b1 != e1; ++b1, ++elem1) {}
596 ar <<
"\nMismatch element : " << elem1 <<
" vs " << elem;
601 for(; b2 != e2; ++b2, ++elem2) {}
603 ar <<
"\nMismatch element : " << elem <<
" vs " << elem2;
612 template<
typename T1,
typename T2>
618 for(elem=0; b1 != e1 && b2 != e2; ++b1, ++b2, ++elem)
620 if(!::iutest::internal::backward::NeHelper<false>::Compare(
"",
"", *b1, *b2))
622 ar << ::iutest::internal::FormatForComparisonFailureMessage(*b1, *b2);
629 if( (b1 != e1) || (b2 != e2) )
644 template<
typename T1,
typename T2>
646 ,
const char* expr2b,
const char* expr2e
647 , T1 b1, T1 e1, T2 b2, T2 e2)
663 template<
typename T1,
typename T2>
665 ,
const char* expr2b,
const char* expr2e
666 , T1 b1, T1 e1, T2 b2, T2 e2)
682 template<
typename T1,
typename T2>
684 , T1 b1, T1 e1, T2 b2, T2 e2)
702 template<
typename T1,
typename T2>
704 ,
const T1& expected,
const T2& actual)
708 , begin(actual), end(actual));
714 template<
typename T1,
typename T2>
716 ,
const T1& expected,
const T2& actual)
720 CmpHelperNeIterator(begin(expected), end(expected), begin(actual), end(actual)))
727 <<
" \n Actual:" << ::iutest::internal::FormatForComparisonFailureMessage(expected, actual);
734 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_
CmpHelperSTRLNEQ(
const char* expr1,
const char* expr2
735 ,
size_t len1,
const char* val2)
737 const size_t len2 = strlen(val2);
743 <<
"\n Actual: " << val2 <<
" : " << len2 <<
"\nExpected: " << len1;
748 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_
CmpHelperSTRLNEQ(
const char* expr1,
const char* expr2
749 ,
size_t len1,
const wchar_t* val2)
751 const size_t len2 = wcslen(val2);
757 <<
"\n Actual: " << val2 <<
" : " << len2 <<
"\nExpected: " << len1;
760 namespace StrInHelper
763 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(
const char* substr,
const char* actual)
765 if( substr == NULL || actual == NULL )
767 return substr == actual;
769 return strstr(actual, substr) != NULL;
772 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(
const wchar_t* substr,
const wchar_t* actual)
774 if( substr == NULL || actual == NULL )
776 return substr == actual;
778 return wcsstr(actual, substr) != NULL;
781 template<
typename Elem,
typename Traits,
typename Ax>
782 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const ::std::basic_string<Elem, Traits, Ax>& substr
783 , const ::std::basic_string<Elem, Traits, Ax>& actual)
785 return Compare(substr.c_str(), actual.c_str());
787 template<
typename Elem,
typename Traits,
typename Ax>
788 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(
const Elem* substr
789 , const ::std::basic_string<Elem, Traits, Ax>& actual)
791 return Compare(substr, actual.c_str());
793 template<
typename Elem,
typename Traits,
typename Ax>
794 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const ::std::basic_string<Elem, Traits, Ax>& substr
795 ,
const Elem* actual)
797 return Compare(substr.c_str(), actual);
800 template<
typename T1,
typename T2>
801 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ Assertion(
const char* substr_str,
const char* actual_str
802 ,
const T1& substr,
const T2& actual)
804 if( Compare(substr, actual) )
810 <<
"\n Actual: " <<
"strstr(\"" << actual <<
"\", " << substr <<
") == NULL";
818 template<
typename T1,
typename T2>
819 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_
CmpHelperSTRIN(
const char* substr_str,
const char* actual_str
820 ,
const T1& substr,
const T2& actual)
822 return StrInHelper::Assertion(substr_str, actual_str, substr, actual);
825 namespace StrNotInHelper
828 template<
typename T1,
typename T2>
829 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(
const T1& substr,
const T2& actual)
831 return !StrInHelper::Compare(substr, actual);
834 template<
typename T1,
typename T2>
835 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ Assertion(
const char* substr_str,
const char* actual_str
836 ,
const T1& substr,
const T2& actual)
838 if( Compare(substr, actual) )
844 <<
"\n Actual: " <<
"strstr(\"" << actual <<
"\", " << substr <<
") != NULL";
852 template<
typename T1,
typename T2>
853 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_
CmpHelperSTRNOTIN(
const char* substr_str,
const char* actual_str
854 ,
const T1& substr,
const T2& actual)
856 return StrNotInHelper::Assertion(substr_str, actual_str, substr, actual);
861 namespace RegexHelper
864 inline bool FullMatch(const ::std::string& str, const ::iutest::internal::RE& re)
866 return ::iutest::internal::RE::FullMatch(str, re);
868 inline bool FullMatch(
const char* str, const ::iutest::internal::RE& re)
874 return ::iutest::internal::RE::FullMatch(str, re);
877 inline bool PartialMatch(const ::std::string& str, const ::iutest::internal::RE& re)
879 return ::iutest::internal::RE::PartialMatch(str, re);
881 inline bool PartialMatch(
const char* str, const ::iutest::internal::RE& re)
887 return ::iutest::internal::RE::PartialMatch(str, re);
892 namespace MatchesRegexEqHelper
895 template<
typename T1,
typename T2>
896 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(
const T1& regex,
const T2& actual)
898 ::iutest::internal::RE iure(regex);
899 return RegexHelper::FullMatch(actual, iure);
902 template<
typename T1,
typename T2>
903 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ Assertion(
const char* regex_str,
const char* actual_str
904 ,
const T1& regex,
const T2& actual)
906 if( Compare(regex, actual) )
910 ::std::string expected_str =
"Matches Regex (";
911 expected_str += regex_str;
914 return ::iutest::internal::EqFailure(expected_str.c_str(), actual_str
925 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperMatchesRegexEq(
const char* regex_str,
const char* actual_str
926 ,
const char* regex,
const char* actual)
928 return MatchesRegexEqHelper::Assertion(regex_str, actual_str, regex, actual);
931 namespace MatchesRegexNeHelper
934 template<
typename T1,
typename T2>
935 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ Assertion(
const char* regex_str,
const char* actual_str
936 ,
const T1& regex,
const T2& actual)
938 if( !MatchesRegexEqHelper::Compare(regex, actual) )
942 ::std::string expected_str =
"Not Matches Regex (";
943 expected_str += regex_str;
946 return ::iutest::internal::EqFailure(expected_str.c_str(), actual_str
957 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperMatchesRegexNe(
const char* regex_str,
const char* actual_str
958 ,
const char* regex,
const char* actual)
960 return MatchesRegexNeHelper::Assertion(regex_str, actual_str, regex, actual);
963 namespace ContainsRegexEqHelper
966 template<
typename T1,
typename T2>
967 inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(
const T1& regex,
const T2& actual)
969 ::iutest::internal::RE m(regex);
970 return RegexHelper::PartialMatch(actual, m);
973 template<
typename T1,
typename T2>
974 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ Assertion(
const char* regex_str,
const char* actual_str
975 ,
const T1& regex,
const T2& actual)
977 if( Compare(regex, actual) )
981 ::std::string expected_str =
"Contains Regex (";
982 expected_str += regex_str;
985 return ::iutest::internal::EqFailure(expected_str.c_str(), actual_str
996 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperContainsRegexEq(
const char* regex_str,
const char* actual_str
997 ,
const char* regex,
const char* actual)
999 return ContainsRegexEqHelper::Assertion(regex_str, actual_str, regex, actual);
1002 namespace ContainsRegexNeHelper
1005 template<
typename T1,
typename T2>
1006 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ Assertion(
const char* regex_str,
const char* actual_str
1007 ,
const T1& regex,
const T2& actual)
1009 if( !ContainsRegexEqHelper::Compare(regex, actual) )
1013 ::std::string expected_str =
"Not Contains Regex (";
1014 expected_str += regex_str;
1015 expected_str +=
")";
1017 return ::iutest::internal::EqFailure(expected_str.c_str(), actual_str
1028 inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperContainsRegexNe(
const char* regex_str,
const char* actual_str
1029 ,
const char* regex,
const char* actual)
1031 return ContainsRegexNeHelper::Assertion(regex_str, actual_str, regex, actual);
1038 #endif // INCG_IRIS_IUTEST_UTIL_ASSERTION_HPP_A45F8265_40E0_44F2_91C6_090B1778657C_