• R/O
  • SSH
  • HTTPS

iutest: Commit


Commit MetaInfo

Revision1423 (tree)
Zeit2020-09-13 16:41:58
Autorsrz_zumix

Log Message

Merge pull request #507 from srz-zumix/fix/greeting

fix greeting
git@0537085997d8c69142b5207e7aa3881ba7773d9c
https://github.com/srz-zumix/iutest/commit/0537085997d8c69142b5207e7aa3881ba7773d9c


Merge remote-tracking branch 'origin/master' into develop

git@cdc14080ab39550cbdbea2cccf0dcdb7f22d0841


update version

git@3bc5f874f3c8f95c7f9c6f0be112505805e31610


add likely/unlikely (#503)

* add likely/unlikely config

* add likely/unlikely

* fix has cond

* support builtin except

* fix typo

* likely/unlikey on assertions

* up

* fix

* add test
git@8eb003079cf14fabe9dcd92b7a984f8a839957ab


support _CPPUNWIND (#502)

git@b2a64d74e7e51085730207f1b23f836e7a443dd5

Ändern Zusammenfassung

Diff

--- trunk/azure-pipelines.yml (revision 1422)
+++ trunk/azure-pipelines.yml (revision 1423)
@@ -109,12 +109,14 @@
109109 - template: .ci/azure_pipelines/template-make-mix-test.yml
110110 parameters:
111111 name: mix
112- - stage: VisualStudioExperimental
112+ - stage: VisualStudio
113113 dependsOn: Precheck
114114 jobs:
115- - job: visual_studio_test
115+ - job: vstest
116116 strategy:
117117 matrix:
118+ NO_EXCEPTION_HANDLER:
119+ CMAKE_OPTIONS: -Dbuild_gtest_samples=ON -Dbuild_no_exceptions=ON
118120 USE_EXPERIMENTAL:
119121 CMAKE_OPTIONS: -Dbuild_gtest_samples=ON -Dbuild_use_experimental=ON
120122 pool:
--- trunk/include/internal/iutest_compiler.hpp (revision 1422)
+++ trunk/include/internal/iutest_compiler.hpp (revision 1423)
@@ -99,6 +99,8 @@
9999
100100
101101 // c++20 features
102+
103+//! has concepts
102104 #if !defined(IUTEST_HAS_CONCEPTS)
103105 # if defined(__cpp_concepts) && __cpp_concepts >= 201907
104106 # define IUTEST_HAS_CONCEPTS 1
@@ -798,7 +800,11 @@
798800 // c++
799801 //! has exceptions
800802 #if !defined(IUTEST_HAS_EXCEPTIONS)
801-# if defined(_MSC_VER) || defined(__BORLANDC__)
803+# if defined(_MSC_VER)
804+# if defined(_CPPUNWIND) && _CPPUNWIND
805+# define IUTEST_HAS_EXCEPTIONS 1
806+# endif
807+# elif defined(__BORLANDC__)
802808 # ifndef _HAS_EXCEPTIONS
803809 # define _HAS_EXCEPTIONS 1
804810 # endif
@@ -826,10 +832,10 @@
826832 #if !defined(IUTEST_HAS_SEH)
827833 # if defined(_WIN32) && !defined(__clang__)
828834 # if defined(_MSC_VER) && _MSC_VER > 1400
829-# define IUTEST_HAS_SEH 1
835+# define IUTEST_HAS_SEH IUTEST_HAS_EXCEPTIONS
830836 # endif
831837 # elif defined(__BORLANDC__)
832-# define IUTEST_HAS_SEH 1
838+# define IUTEST_HAS_SEH IUTEST_HAS_EXCEPTIONS
833839 # endif
834840 #endif
835841
@@ -1190,11 +1196,53 @@
11901196 # define IUTEST_HAS_ATTRIBUTE 0
11911197 #endif
11921198
1199+//! has likely/unlikely attribute
1200+#if !defined(IUTEST_HAS_ATTRIBUTE_LIKELY_UNLIKELY)
1201+# if defined(__has_cpp_attribute)
1202+# if __has_cpp_attribute(likely) >= 201803L && __has_cpp_attribute(unlikely) >= 201803L
1203+# if defined(__GNUC__) && (__GNUC__ <= 9)
1204+// gcc 9.X likely is experimental. can be used in switch~case, cannot be used in if statement
1205+# define IUTEST_HAS_ATTRIBUTE_LIKELY_UNLIKELY 0
1206+# else
1207+# define IUTEST_HAS_ATTRIBUTE_LIKELY_UNLIKELY IUTEST_HAS_ATTRIBUTE
1208+# endif
1209+# endif
1210+# endif
1211+#endif
1212+
1213+#if !defined(IUTEST_HAS_ATTRIBUTE_LIKELY_UNLIKELY)
1214+# define IUTEST_HAS_ATTRIBUTE_LIKELY_UNLIKELY 0
1215+#endif
1216+
1217+//! likely attribute
1218+#if !defined(IUTEST_ATTRIBUTE_LIKELY_)
1219+# if IUTEST_HAS_ATTRIBUTE_LIKELY_UNLIKELY
1220+# define IUTEST_ATTRIBUTE_LIKELY_ [[likely]]
1221+# else
1222+# endif
1223+#endif
1224+
1225+#if !defined(IUTEST_ATTRIBUTE_LIKELY_)
1226+# define IUTEST_ATTRIBUTE_LIKELY_
1227+#endif
1228+
1229+//! unlikely attribute
1230+#if !defined(IUTEST_ATTRIBUTE_UNLIKELY_)
1231+# if IUTEST_HAS_ATTRIBUTE_LIKELY_UNLIKELY
1232+# define IUTEST_ATTRIBUTE_UNLIKELY_ [[unlikely]]
1233+# else
1234+# endif
1235+#endif
1236+
1237+#if !defined(IUTEST_ATTRIBUTE_UNLIKELY_)
1238+# define IUTEST_ATTRIBUTE_UNLIKELY_
1239+#endif
1240+
11931241 //! has deprecated attribute
11941242 #if !defined(IUTEST_HAS_ATTRIBUTE_DEPRECATED)
11951243 # if defined(__has_cpp_attribute)
11961244 # if __has_cpp_attribute(deprecated) >= 201309
1197-# define IUTEST_HAS_ATTRIBUTE_DEPRECATED 1
1245+# define IUTEST_HAS_ATTRIBUTE_DEPRECATED IUTEST_HAS_ATTRIBUTE
11981246 # endif
11991247 # elif defined(__GNUC__)
12001248 # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) && defined(__GXX_EXPERIMENTAL_CXX0X__)
@@ -1313,6 +1361,39 @@
13131361 #endif
13141362
13151363
1364+// builtin
1365+
1366+//! builtin expect
1367+#if !defined(IUTEST_HAS_BUILTIN_EXPECT)
1368+# if defined(__clang__) || defined(__GNUC__)
1369+# define IUTEST_HAS_BUILTIN_EXPECT 1
1370+# endif
1371+#endif
1372+
1373+#if !defined(IUTEST_HAS_BUILTIN_EXPECT)
1374+# define IUTEST_HAS_BUILTIN_EXPECT 0
1375+#endif
1376+
1377+#if !defined(IUTEST_COND_LIKELY)
1378+# if IUTEST_HAS_ATTRIBUTE_LIKELY_UNLIKELY
1379+# define IUTEST_COND_LIKELY(cond) (cond) IUTEST_ATTRIBUTE_LIKELY_
1380+# elif IUTEST_HAS_BUILTIN_EXPECT
1381+# define IUTEST_COND_LIKELY(cond) (__builtin_expect(static_cast<bool>(!!(cond)), 1))
1382+# else
1383+# define IUTEST_COND_LIKELY(cond) (cond)
1384+# endif
1385+#endif
1386+
1387+#if !defined(IUTEST_COND_UNLIKELY)
1388+# if IUTEST_HAS_ATTRIBUTE_LIKELY_UNLIKELY
1389+# define IUTEST_COND_UNLIKELY(cond) (cond) IUTEST_ATTRIBUTE_UNLIKELY_
1390+# elif IUTEST_HAS_BUILTIN_EXPECT
1391+# define IUTEST_COND_UNLIKELY(cond) (__builtin_expect(static_cast<bool>(!!(cond)), 0))
1392+# else
1393+# define IUTEST_COND_UNLIKELY(cond) (cond)
1394+# endif
1395+#endif
1396+
13161397 //! MemorySanitizer
13171398 #if !defined(IUTEST_HAS_MEMORY_SANITIZER)
13181399 # if defined(__has_feature)
--- trunk/include/internal/iutest_internal.hpp (revision 1422)
+++ trunk/include/internal/iutest_internal.hpp (revision 1423)
@@ -414,7 +414,7 @@
414414 #define IUTEST_TEST_BOOLEAN_(expression, text, actual, expected, on_failure) \
415415 IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \
416416 if( const ::iutest::AssertionResult iutest_ar = ::iutest::AssertionResult::Is(expression) ) \
417- ; \
417+ IUTEST_ATTRIBUTE_LIKELY_; \
418418 else \
419419 on_failure(::iutest::internal::GetBooleanAssertionFailureMessage( \
420420 iutest_ar, text, #actual, #expected).c_str() )
@@ -423,7 +423,7 @@
423423 * @internal
424424 * @brief assert
425425 */
426-#define IUTEST_ASSERT_EXIT(cond) do { if( !(cond) ) { \
426+#define IUTEST_ASSERT_EXIT(cond) do { if IUTEST_COND_UNLIKELY( !(cond) ) { \
427427 IUTEST_MESSAGE(#cond, ::iutest::TestPartResult::kFatalFailure); \
428428 exit(1); \
429429 } } while(::iutest::detail::AlwaysFalse())
--- trunk/include/internal/iutest_option_message.hpp (revision 1422)
+++ trunk/include/internal/iutest_option_message.hpp (revision 1423)
@@ -178,6 +178,8 @@
178178 IIUT_SHOW_MACRO(IUTEST_CPLUSPLUS);
179179 IIUT_SHOW_MACRO(IUTEST_HAS_ANALYSIS_ASSUME);
180180 IIUT_SHOW_MACRO(IUTEST_HAS_ATTRIBUTE);
181+ IIUT_SHOW_MACRO(IUTEST_HAS_ATTRIBUTE_DEPRECATED);
182+ IIUT_SHOW_MACRO(IUTEST_HAS_ATTRIBUTE_LIKELY_UNLIKELY);
181183 IIUT_SHOW_MACRO(IUTEST_HAS_AUTO);
182184 IIUT_SHOW_MACRO(IUTEST_HAS_CATCH_SEH_EXCEPTION_ASSERTION);
183185 IIUT_SHOW_MACRO(IUTEST_HAS_CHAR16_T);
--- trunk/include/iutest_assertion.hpp (revision 1422)
+++ trunk/include/iutest_assertion.hpp (revision 1423)
@@ -353,8 +353,8 @@
353353 detail::DefaultReportTestPartResult(m_part_result);
354354 }
355355
356- if( m_part_result.failed()
357- && TestFlag::IsEnableFlag(iutest::TestFlag::BREAK_ON_FAILURE) )
356+ if IUTEST_COND_UNLIKELY(m_part_result.failed()
357+ && TestFlag::IsEnableFlag(iutest::TestFlag::BREAK_ON_FAILURE))
358358 {
359359 IUTEST_BREAK();
360360 }
@@ -493,7 +493,7 @@
493493 #define IIUT_DECL_COMPARE_HELPER_I_(op_name, op, type1, type2) \
494494 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelper##op_name( \
495495 const char* expr1, const char* expr2, type1 val1, type2 val2) { \
496- if( iuOperator##op_name(val1, val2) ) { return AssertionSuccess(); \
496+ if IUTEST_COND_LIKELY(iuOperator##op_name(val1, val2)) { return AssertionSuccess(); \
497497 } else { return CmpHelperOpFailure(expr1, expr2, #op, val1, val2); } \
498498 }
499499
@@ -552,7 +552,7 @@
552552 template<typename T>
553553 static AssertionResult CompareEq(const char* expr, const T* val)
554554 {
555- if( IUTEST_NULLPTR == val )
555+ if IUTEST_COND_LIKELY( IUTEST_NULLPTR == val )
556556 {
557557 return AssertionSuccess();
558558 }
@@ -564,7 +564,7 @@
564564 template<typename T>
565565 static AssertionResult CompareNe(const char* expr, const T* val)
566566 {
567- if( IUTEST_NULLPTR != val )
567+ if IUTEST_COND_LIKELY( IUTEST_NULLPTR != val )
568568 {
569569 return AssertionSuccess();
570570 }
@@ -596,7 +596,7 @@
596596 inline AssertionResult CmpHelperSame(const char* expected_str, const char* actual_str
597597 , const T1& expected, const T2& actual)
598598 {
599- if( &expected == &actual )
599+ if IUTEST_COND_LIKELY( &expected == &actual )
600600 {
601601 return AssertionSuccess();
602602 }
@@ -610,7 +610,7 @@
610610 inline AssertionResult CmpHelperEQ(const char* expected_str, const char* actual_str
611611 , const T1& expected, const T2& actual)
612612 {
613- if( iuOperatorEQ(actual, expected) )
613+ if IUTEST_COND_LIKELY( iuOperatorEQ(actual, expected) )
614614 {
615615 return AssertionSuccess();
616616 }
@@ -628,7 +628,7 @@
628628 IUTEST_PRAGMA_WARN_PUSH()
629629 IUTEST_PRAGMA_WARN_DISABLE_SIGN_COMPARE()
630630
631- if( memcmp(&actual, &expected, sizeof(T)) == 0 )
631+ if IUTEST_COND_LIKELY( memcmp(&actual, &expected, sizeof(T)) == 0 )
632632 {
633633 return AssertionSuccess();
634634 }
@@ -648,7 +648,7 @@
648648 IUTEST_PRAGMA_WARN_PUSH()
649649 IUTEST_PRAGMA_WARN_DISABLE_SIGN_COMPARE()
650650
651- if( memcmp(&actual, &expected, sizeof(T)) != 0 )
651+ if IUTEST_COND_LIKELY( memcmp(&actual, &expected, sizeof(T)) != 0 )
652652 {
653653 return AssertionSuccess();
654654 }
@@ -664,7 +664,7 @@
664664 , RawType val1, RawType val2)
665665 {
666666 floating_point<RawType> f1(val1), f2(val2);
667- if( f1.AlmostEquals(f2) )
667+ if IUTEST_COND_LIKELY( f1.AlmostEquals(f2) )
668668 {
669669 return AssertionSuccess();
670670 }
@@ -677,12 +677,12 @@
677677 inline AssertionResult CmpHelperFloatingPointLE(const char* expr1, const char* expr2
678678 , RawType val1, RawType val2)
679679 {
680- if( val1 < val2 )
680+ if IUTEST_COND_LIKELY( val1 < val2 )
681681 {
682682 return AssertionSuccess();
683683 }
684684 floating_point<RawType> f1(val1), f2(val2);
685- if( f1.AlmostEquals(f2) )
685+ if IUTEST_COND_LIKELY( f1.AlmostEquals(f2) )
686686 {
687687 return AssertionSuccess();
688688 }
@@ -926,13 +926,13 @@
926926 const char* expr1, const char* expr2, const char* absc
927927 , RawType val1, RawType val2, RawType abs_v)
928928 {
929- RawType diff = val1 > val2 ? val1 - val2 : val2 - val1;
930- if( diff < abs_v )
929+ const RawType diff = val1 > val2 ? val1 - val2 : val2 - val1;
930+ if IUTEST_COND_LIKELY( diff < abs_v )
931931 {
932932 return AssertionSuccess();
933933 }
934934 floating_point<RawType> f1(diff), f2(abs_v);
935- if( f1.AlmostEquals(f2) )
935+ if IUTEST_COND_LIKELY( f1.AlmostEquals(f2) )
936936 {
937937 return AssertionSuccess();
938938 }
@@ -952,8 +952,8 @@
952952 const char* expr1, const char* expr2, const char* absc
953953 , const T& val1, const T& val2, const A& abs_v)
954954 {
955- T diff = val1 > val2 ? val1 - val2 : val2 - val1;
956- if( diff <= abs_v )
955+ const T diff = val1 > val2 ? val1 - val2 : val2 - val1;
956+ if IUTEST_COND_LIKELY( diff <= abs_v )
957957 {
958958 return AssertionSuccess();
959959 }
@@ -1025,7 +1025,7 @@
10251025 , T1 val1, T2 val2, typename detail::enable_if<
10261026 !detail::is_integral<T1>::value || !detail::is_pointer<T2>::value, void>::type*& = detail::enabler::value)
10271027 {
1028- if( StrEqHelper::Compare(val1, val2) )
1028+ if IUTEST_COND_LIKELY( StrEqHelper::Compare(val1, val2) )
10291029 {
10301030 return AssertionSuccess();
10311031 }
@@ -1040,7 +1040,7 @@
10401040 const char* expr1, const char* expr2
10411041 , detail::iu_nullptr_convertible_t, T val2)
10421042 {
1043- if( StrEqHelper::Compare(IUTEST_NULLPTR, val2) )
1043+ if IUTEST_COND_LIKELY( StrEqHelper::Compare(IUTEST_NULLPTR, val2) )
10441044 {
10451045 return AssertionSuccess();
10461046 }
@@ -1068,7 +1068,7 @@
10681068 ((!detail::is_integral<T2>::value || !detail::is_pointer<T1>::value) &&
10691069 (!detail::is_integral<T1>::value || !detail::is_pointer<T2>::value)), void>::type*& = detail::enabler::value)
10701070 {
1071- if( StrNeHelper::Compare(val1, val2) )
1071+ if IUTEST_COND_LIKELY( StrNeHelper::Compare(val1, val2) )
10721072 {
10731073 return AssertionSuccess();
10741074 }
@@ -1083,7 +1083,7 @@
10831083 const char* expr1, const char* expr2
10841084 , detail::iu_nullptr_convertible_t, T val2)
10851085 {
1086- if( !StrEqHelper::Compare(IUTEST_NULLPTR, val2) )
1086+ if IUTEST_COND_LIKELY( !StrEqHelper::Compare(IUTEST_NULLPTR, val2) )
10871087 {
10881088 return AssertionSuccess();
10891089 }
@@ -1098,7 +1098,7 @@
10981098 const char* expr1, const char* expr2
10991099 , T val1, detail::iu_nullptr_convertible_t)
11001100 {
1101- if( !StrEqHelper::Compare(val1, IUTEST_NULLPTR) )
1101+ if IUTEST_COND_LIKELY( !StrEqHelper::Compare(val1, IUTEST_NULLPTR) )
11021102 {
11031103 return AssertionSuccess();
11041104 }
@@ -1156,7 +1156,7 @@
11561156 const char* expr1, const char* expr2
11571157 , const T1& val1, const T2& val2)
11581158 {
1159- if( Compare(val1, val2) )
1159+ if IUTEST_COND_LIKELY( Compare(val1, val2) )
11601160 {
11611161 return AssertionSuccess();
11621162 }
@@ -1218,7 +1218,7 @@
12181218 const char* expr1, const char* expr2
12191219 , const T1& val1, const T2& val2)
12201220 {
1221- if( Compare(val1, val2) )
1221+ if IUTEST_COND_LIKELY( Compare(val1, val2) )
12221222 {
12231223 return AssertionSuccess();
12241224 }
@@ -1271,7 +1271,7 @@
12711271
12721272 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ IsHRESULTSuccess(const char* expr, HRESULT hr)
12731273 {
1274- if( SUCCEEDED(hr) )
1274+ if IUTEST_COND_LIKELY( SUCCEEDED(hr) )
12751275 {
12761276 return AssertionSuccess();
12771277 }
@@ -1280,7 +1280,7 @@
12801280 }
12811281 inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ IsHRESULTFailure(const char* expr, HRESULT hr)
12821282 {
1283- if( FAILED(hr) )
1283+ if IUTEST_COND_LIKELY( FAILED(hr) )
12841284 {
12851285 return AssertionSuccess();
12861286 }
--- trunk/include/iutest_matcher.hpp (revision 1422)
+++ trunk/include/iutest_matcher.hpp (revision 1423)
@@ -100,7 +100,7 @@
100100 strm << #name ": " << m_expected; return strm.str(); \
101101 } \
102102 template<typename U>AssertionResult operator ()(const U& actual) const { \
103- if( actual op m_expected ) return AssertionSuccess(); \
103+ if IUTEST_COND_LIKELY( actual op m_expected ) return AssertionSuccess();\
104104 return AssertionFailure() << WhichIs(); \
105105 } \
106106 private: const T& m_expected; \
@@ -111,7 +111,7 @@
111111 public: ::std::string WhichIs() const IUTEST_CXX_OVERRIDE { return #name; } \
112112 template<typename T, typename U>AssertionResult operator () \
113113 (const T& actual, const U& expected) const { \
114- if( actual op expected ) return AssertionSuccess(); \
114+ if IUTEST_COND_LIKELY( actual op expected ) return AssertionSuccess(); \
115115 return AssertionFailure() << WhichIs() << ": " << actual << " vs " << expected; \
116116 } \
117117 }
@@ -142,7 +142,7 @@
142142 template<typename T>class IUTEST_PP_CAT(name, Matcher): public IMatcher { \
143143 public: IUTEST_PP_CAT(name, Matcher)(const T& value) : m_expected(value) {} \
144144 template<typename U>AssertionResult operator ()(const U& actual) const { \
145- if( internal::IUTEST_PP_CAT(name, Helper)::Compare( \
145+ if IUTEST_COND_LIKELY( internal::IUTEST_PP_CAT(name, Helper)::Compare( \
146146 actual, m_expected) ) { return AssertionSuccess(); } \
147147 return AssertionFailure() << WhichIs(); \
148148 } \
@@ -174,7 +174,7 @@
174174 template<typename U>
175175 AssertionResult operator ()(const U* actual) const
176176 {
177- if( actual == NULL )
177+ if IUTEST_COND_LIKELY( actual == NULL )
178178 {
179179 return AssertionSuccess();
180180 }
@@ -195,7 +195,7 @@
195195 template<typename U>
196196 AssertionResult operator ()(const U* actual) const
197197 {
198- if( actual != NULL )
198+ if IUTEST_COND_LIKELY( actual != NULL )
199199 {
200200 return AssertionSuccess();
201201 }
@@ -220,8 +220,8 @@
220220 template<typename U>
221221 AssertionResult operator ()(const U& actual) const
222222 {
223- floating_point<T> f2(actual);
224- if( m_expected.AlmostEquals(f2) )
223+ const floating_point<T> f2(actual);
224+ if IUTEST_COND_LIKELY( m_expected.AlmostEquals(f2) )
225225 {
226226 return AssertionSuccess();
227227 }
@@ -251,8 +251,8 @@
251251 template<typename U>
252252 AssertionResult operator ()(const U& actual) const
253253 {
254- floating_point<T> f2(actual);
255- if( m_expected.NanSensitiveAlmostEquals(f2) )
254+ const floating_point<T> f2(actual);
255+ if IUTEST_COND_LIKELY( m_expected.NanSensitiveAlmostEquals(f2) )
256256 {
257257 return AssertionSuccess();
258258 }
@@ -283,8 +283,8 @@
283283 template<typename U>
284284 AssertionResult operator ()(const U& actual) const
285285 {
286- floating_point<T> a(actual);
287- if( m_expected.AlmostNear(a, m_max_abs_error) )
286+ const floating_point<T> a(actual);
287+ if IUTEST_COND_LIKELY( m_expected.AlmostNear(a, m_max_abs_error) )
288288 {
289289 return AssertionSuccess();
290290 }
@@ -316,8 +316,8 @@
316316 template<typename U>
317317 AssertionResult operator ()(const U& actual) const
318318 {
319- floating_point<T> a(actual);
320- if( m_expected.NanSensitiveAlmostNear(a, m_max_abs_error) )
319+ const floating_point<T> a(actual);
320+ if IUTEST_COND_LIKELY( m_expected.NanSensitiveAlmostNear(a, m_max_abs_error) )
321321 {
322322 return AssertionSuccess();
323323 }
@@ -348,7 +348,7 @@
348348 template<typename U>
349349 AssertionResult operator ()(const U& actual) const
350350 {
351- if( StartsWith(actual, m_expected) )
351+ if IUTEST_COND_LIKELY( StartsWith(actual, m_expected) )
352352 {
353353 return AssertionSuccess();
354354 }
@@ -398,7 +398,7 @@
398398 template<typename U>
399399 AssertionResult operator ()(const U& actual) const
400400 {
401- if( HasSubstr(actual, m_expected) )
401+ if IUTEST_COND_LIKELY( HasSubstr(actual, m_expected) )
402402 {
403403 return AssertionSuccess();
404404 }
@@ -450,7 +450,7 @@
450450 template<typename U>
451451 AssertionResult operator ()(const U& actual) const
452452 {
453- if( EndsWith(actual, m_expected) )
453+ if IUTEST_COND_LIKELY( EndsWith(actual, m_expected) )
454454 {
455455 return AssertionSuccess();
456456 }
@@ -516,7 +516,7 @@
516516 template<typename U>
517517 AssertionResult operator ()(const U& actual) const
518518 {
519- if( Equals(actual, m_expected) )
519+ if IUTEST_COND_LIKELY( Equals(actual, m_expected) )
520520 {
521521 return AssertionSuccess();
522522 }
@@ -621,7 +621,7 @@
621621 AssertionResult operator ()(const U& actual)
622622 {
623623 IUTEST_USING_BEGIN_END();
624- if( Contains(begin(actual), end(actual)) )
624+ if IUTEST_COND_LIKELY( Contains(begin(actual), end(actual)) )
625625 {
626626 return AssertionSuccess();
627627 }
@@ -669,7 +669,7 @@
669669 AssertionResult operator ()(const U& actual)
670670 {
671671 IUTEST_USING_BEGIN_END();
672- if( Each(begin(actual), end(actual)) )
672+ if IUTEST_COND_LIKELY( Each(begin(actual), end(actual)) )
673673 {
674674 return AssertionSuccess();
675675 }
@@ -717,7 +717,7 @@
717717 AssertionResult operator ()(const U& actual)
718718 {
719719 IUTEST_USING_BEGIN_END();
720- if( Check(begin(m_expected), end(m_expected)
720+ if IUTEST_COND_LIKELY( Check(begin(m_expected), end(m_expected)
721721 , begin(actual), end(actual)) )
722722 {
723723 return AssertionSuccess();
@@ -784,7 +784,7 @@
784784 AssertionResult operator ()(const U& actual)
785785 {
786786 IUTEST_USING_BEGIN_END();
787- if( Check(begin(m_expected), end(m_expected)
787+ if IUTEST_COND_LIKELY( Check(begin(m_expected), end(m_expected)
788788 , begin(actual), end(actual)) )
789789 {
790790 return AssertionSuccess();
@@ -844,7 +844,7 @@
844844 template<typename U>
845845 AssertionResult operator ()(const U& actual)
846846 {
847- if( (actual).empty() )
847+ if IUTEST_COND_LIKELY( (actual).empty() )
848848 {
849849 return AssertionSuccess();
850850 }
@@ -872,7 +872,7 @@
872872 template<typename U>
873873 AssertionResult operator ()(const U& actual)
874874 {
875- if( Check(actual) )
875+ if IUTEST_COND_LIKELY( Check(actual) )
876876 {
877877 return AssertionSuccess();
878878 }
@@ -917,7 +917,7 @@
917917 template<typename U>
918918 AssertionResult operator ()(const U& actual)
919919 {
920- if( CastToMatcher(m_expected)(actual[m_index]) )
920+ if IUTEST_COND_LIKELY( CastToMatcher(m_expected)(actual[m_index]) )
921921 {
922922 return AssertionSuccess();
923923 }
@@ -984,13 +984,13 @@
984984 {
985985 const size_t actual_cnt = ::std::distance(actual_begin, actual_end);
986986 const size_t expected_cnt = m_expected.size();
987- if( actual_cnt < expected_cnt )
987+ if IUTEST_COND_UNLIKELY( actual_cnt < expected_cnt )
988988 {
989989 iu_global_format_stringstream stream;
990990 stream << "actual argument[" << actual_cnt << "] is less than " << expected_cnt;
991991 return AssertionFailure() << WhichIs(stream.str());
992992 }
993- if( m_expected_elem_count && actual_cnt > expected_cnt )
993+ if IUTEST_COND_UNLIKELY( m_expected_elem_count && actual_cnt > expected_cnt )
994994 {
995995 iu_global_format_stringstream stream;
996996 stream << "actual argument[" << actual_cnt << "] is greater than " << expected_cnt;
@@ -1002,7 +1002,7 @@
10021002 for( int i=0; it_a != actual_end && it_e != m_expected.end(); ++it_e, ++it_a, ++i )
10031003 {
10041004 (void)i;
1005- if( *it_a != *it_e )
1005+ if IUTEST_COND_UNLIKELY( *it_a != *it_e )
10061006 {
10071007 return AssertionFailure() << WhichIs();
10081008 }
@@ -1042,7 +1042,7 @@
10421042 static AssertionResult Check(Ite it, Ite end, M& matchers)
10431043 {
10441044 const size_t cnt = ::std::distance(it, end);
1045- if( cnt < LAST+1 )
1045+ if IUTEST_COND_UNLIKELY( cnt < LAST+1 )
10461046 {
10471047 return AssertionFailure() << "ElementsAre: argument[" << cnt << "] is less than " << LAST+1;
10481048 }
@@ -1056,7 +1056,7 @@
10561056 for( int index=N; it != end; ++it, ++index )
10571057 {
10581058 AssertionResult ar = CastToMatcher(tuples::get<N>(matchers))(*it);
1059- if( !ar )
1059+ if IUTEST_COND_UNLIKELY( !ar )
10601060 {
10611061 return AssertionFailure() << WhichIsElem<N>(matchers, index);
10621062 }
@@ -1069,7 +1069,7 @@
10691069 , typename detail::disable_if<N == LAST, void>::type*& = detail::enabler::value)
10701070 {
10711071 AssertionResult ar = CastToMatcher(tuples::get<N>(matchers))(*it);
1072- if( ar )
1072+ if IUTEST_COND_LIKELY( ar )
10731073 {
10741074 return CheckElem<N + 1, LAST>(++it, end, matchers);
10751075 }
@@ -1191,7 +1191,7 @@
11911191 template<typename U>
11921192 AssertionResult operator ()(const U& actual)
11931193 {
1194- if( Check(actual) )
1194+ if IUTEST_COND_LIKELY( Check(actual) )
11951195 {
11961196 return AssertionSuccess();
11971197 }
@@ -1246,7 +1246,7 @@
12461246 template<typename U>
12471247 AssertionResult operator ()(const U& actual)
12481248 {
1249- if( Check(actual) )
1249+ if IUTEST_COND_LIKELY( Check(actual) )
12501250 {
12511251 return AssertionSuccess();
12521252 }
@@ -1301,7 +1301,7 @@
13011301 template<typename U>
13021302 AssertionResult operator ()(const U& actual) const
13031303 {
1304- if( CastToMatcher(m_expected)(actual.first) )
1304+ if IUTEST_COND_LIKELY( CastToMatcher(m_expected)(actual.first) )
13051305 {
13061306 return AssertionSuccess();
13071307 }
@@ -1333,11 +1333,11 @@
13331333 template<typename U>
13341334 AssertionResult operator ()(const U& actual)
13351335 {
1336- if( !CheckElem(actual.first, m_m1) )
1336+ if IUTEST_COND_UNLIKELY( !CheckElem(actual.first, m_m1) )
13371337 {
13381338 return AssertionFailure() << WhichIs();
13391339 }
1340- if( !CheckElem(actual.second, m_m2) )
1340+ if IUTEST_COND_UNLIKELY( !CheckElem(actual.second, m_m2) )
13411341 {
13421342 return AssertionFailure() << WhichIs();
13431343 }
@@ -1376,7 +1376,7 @@
13761376 template<typename U>
13771377 AssertionResult operator ()(const U& actual)
13781378 {
1379- if( Check(actual) )
1379+ if IUTEST_COND_LIKELY( Check(actual) )
13801380 {
13811381 return AssertionSuccess();
13821382 }
@@ -1415,7 +1415,7 @@
14151415 template<typename U>
14161416 AssertionResult operator ()(const U& actual)
14171417 {
1418- if( Check(actual) )
1418+ if IUTEST_COND_LIKELY( Check(actual) )
14191419 {
14201420 return AssertionSuccess();
14211421 }
@@ -1452,7 +1452,7 @@
14521452 template<typename U>
14531453 AssertionResult operator ()(const U& actual)
14541454 {
1455- if( !CastToMatcher(m_unexpected)(actual) )
1455+ if IUTEST_COND_LIKELY( !CastToMatcher(m_unexpected)(actual) )
14561456 {
14571457 return AssertionSuccess();
14581458 }
@@ -1529,7 +1529,7 @@
15291529 template<typename U>
15301530 AssertionResult operator ()(const U& actual) const
15311531 {
1532- if( Regex(actual) )
1532+ if IUTEST_COND_LIKELY( Regex(actual) )
15331533 {
15341534 return AssertionSuccess();
15351535 }
@@ -1592,7 +1592,7 @@
15921592 static AssertionResult Check_(T& matchers, const U& actual, typename detail::enable_if<N == LAST, void>::type*& = detail::enabler::value)
15931593 {
15941594 AssertionResult ar = tuples::get<N>(matchers)(actual);
1595- if( ar )
1595+ if IUTEST_COND_LIKELY( ar )
15961596 {
15971597 return ar;
15981598 }
@@ -1602,7 +1602,7 @@
16021602 static AssertionResult Check_(T& matchers, const U& actual, typename detail::disable_if<N == LAST, void>::type*& = detail::enabler::value)
16031603 {
16041604 AssertionResult ar = tuples::get<N>(matchers)(actual);
1605- if( ar )
1605+ if IUTEST_COND_LIKELY( ar )
16061606 {
16071607 return Check_<T, U, N + 1, LAST>(matchers, actual);
16081608 }
@@ -1719,7 +1719,7 @@
17191719 static AssertionResult Check_(T& matchers, const U& actual, typename detail::enable_if<N == LAST, void>::type*& = detail::enabler::value)
17201720 {
17211721 AssertionResult ar = tuples::get<N>(matchers)(actual);
1722- if( ar )
1722+ if IUTEST_COND_LIKELY( ar )
17231723 {
17241724 return ar;
17251725 }
@@ -1729,7 +1729,7 @@
17291729 static AssertionResult Check_(T& matchers, const U& actual, typename detail::disable_if<N == LAST, void>::type*& = detail::enabler::value)
17301730 {
17311731 AssertionResult ar = tuples::get<N>(matchers)(actual);
1732- if( ar )
1732+ if IUTEST_COND_LIKELY( ar )
17331733 {
17341734 return ar;
17351735 }
--- trunk/include/iutest_pred.hpp (revision 1422)
+++ trunk/include/iutest_pred.hpp (revision 1423)
@@ -6,7 +6,7 @@
66 *
77 * @author t.shirayanagi
88 * @par copyright
9- * Copyright (C) 2011-2016, Takazumi Shirayanagi\n
9+ * Copyright (C) 2011-2020, Takazumi Shirayanagi\n
1010 * This software is released under the new BSD License,
1111 * see LICENSE
1212 */
@@ -620,7 +620,7 @@
620620 AssertionResult AssertPred1Helper(const char* pred_str, const char* expr1
621621 , PRED pred, T1 val1)
622622 {
623- if( (*pred)(val1) )
623+ if IUTEST_COND_LIKELY( (*pred)(val1) )
624624 {
625625 return AssertionSuccess();
626626 }
@@ -633,7 +633,7 @@
633633 AssertionResult AssertPred2Helper(const char* pred_str, const char* expr1, const char* expr2
634634 , PRED pred, T1 val1, T2 val2)
635635 {
636- if( (*pred)(val1, val2) )
636+ if IUTEST_COND_LIKELY( (*pred)(val1, val2) )
637637 {
638638 return AssertionSuccess();
639639 }
@@ -650,7 +650,7 @@
650650 , const char* expr1, const char* expr2, const char* expr3
651651 , PRED pred, T1 val1, T2 val2, T3 val3)
652652 {
653- if( (*pred)(val1, val2, val3) )
653+ if IUTEST_COND_LIKELY( (*pred)(val1, val2, val3) )
654654 {
655655 return AssertionSuccess();
656656 }
@@ -668,7 +668,7 @@
668668 , const char* expr1, const char* expr2, const char* expr3, const char* expr4
669669 , PRED pred, T1 val1, T2 val2, T3 val3, T4 val4)
670670 {
671- if( (*pred)(val1, val2, val3, val4) )
671+ if IUTEST_COND_LIKELY( (*pred)(val1, val2, val3, val4) )
672672 {
673673 return AssertionSuccess();
674674 }
@@ -687,7 +687,7 @@
687687 , const char* expr1, const char* expr2, const char* expr3, const char* expr4, const char* expr5
688688 , PRED pred, T1 val1, T2 val2, T3 val3, T4 val4, T5 val5)
689689 {
690- if( (*pred)(val1, val2, val3, val4, val5) )
690+ if IUTEST_COND_LIKELY( (*pred)(val1, val2, val3, val4, val5) )
691691 {
692692 return AssertionSuccess();
693693 }
@@ -708,7 +708,7 @@
708708 AssertionResult AssertPredVariadicHelper(const char* pred_str, const char* params
709709 , PRED pred, Args... args)
710710 {
711- if( (*pred)(args...) )
711+ if IUTEST_COND_LIKELY( (*pred)(args...) )
712712 {
713713 return AssertionSuccess();
714714 }
--- trunk/include/iutest_ver.hpp (revision 1422)
+++ trunk/include/iutest_ver.hpp (revision 1423)
@@ -17,11 +17,11 @@
1717
1818 //======================================================================
1919 // define
20-#define IUTEST_VER 0x01179900u //!< iutest version 1.17.99.0
20+#define IUTEST_VER 0x01179901u //!< iutest version 1.17.99.1
2121 #define IUTEST_MAJORVER 0x01u //!< Major Version
2222 #define IUTEST_MINORVER 0x17u //!< Minor Version
2323 #define IUTEST_MICROVER 0x99u //!< Micro Version
24-#define IUTEST_REVISION 0x00u //!< Revision
24+#define IUTEST_REVISION 0x01u //!< Revision
2525
2626 #define IUTEST_BUILD IUTEST_MICROVER //!< @deprecated
2727
--- trunk/test/spi_tests_decl.cpp (revision 1422)
+++ trunk/test/spi_tests_decl.cpp (revision 1423)
@@ -34,6 +34,7 @@
3434 FAILURE_MACRO( FLAVOR(_SAME)(a, b), "" );
3535 #if IUTEST_HAS_ASSERTION_NOEQUALTO_OBJECT
3636 FAILURE_MACRO( FLAVOR(_EQ)(ox, oy), "" );
37+ FAILURE_MACRO( FLAVOR(_NE)(ox, ox), "" );
3738 #endif
3839 FAILURE_MACRO( FLAVOR(_EQ)(0, 1), "" );
3940 FAILURE_MACRO( FLAVOR(_NE)(1, 1), "" );
@@ -90,7 +91,6 @@
9091 FAILURE_MACRO( FLAVOR(_STRCASENE)(sa, sa), "" );
9192 FAILURE_MACRO( FLAVOR(_STRCASENE)(L"A", L"a"), "" );
9293
93-
9494 FAILURE_MACRO( FLAVOR(_PRED1)(IsOdd, 2), "evaluates to false, where" );
9595 FAILURE_MACRO( FLAVOR(_PRED2)(IsGreater, 0, 1), "evaluates to false, where" );
9696 FAILURE_MACRO( FLAVOR(_PRED3)(PredTest3, 0, 1, 3), "evaluates to false, where" );
Show on old repository browser