@@ -568,18 +568,22 @@ struct with_what_contains : private contains_substring {
568568# define WARNING_PUSH _Pragma (" clang diagnostic push" )
569569# define WARNING_POP _Pragma (" clang diagnostic pop" )
570570# define WARNING_DISABLE_PARENTHESES do {} while (0 )
571+ # define WARNING_DISABLE_CONSTANT_COMPARISON do {} while (0 )
571572#elif defined(__GNUC__)
572573# define WARNING_PUSH _Pragma (" GCC diagnostic push" )
573574# define WARNING_POP _Pragma (" GCC diagnostic pop" )
574575# define WARNING_DISABLE_PARENTHESES _Pragma (" GCC diagnostic ignored \" -Wparentheses\" " )
576+ # define WARNING_DISABLE_CONSTANT_COMPARISON do {} while (0 )
575577#elif defined(_MSC_VER)
576- # define WARNING_PUSH do {} while ( 0 )
577- # define WARNING_POP do {} while ( 0 )
578+ # define WARNING_PUSH do {} _Pragma ( " warning(push) " )
579+ # define WARNING_POP do {} _Pragma ( " warning(pop) " )
578580# define WARNING_DISABLE_PARENTHESES do {} while (0 )
581+ # define WARNING_DISABLE_CONSTANT_COMPARISON _Pragma (" warning(disable: 4127)" )
579582#else
580583# define WARNING_PUSH do {} while (0 )
581584# define WARNING_POP do {} while (0 )
582585# define WARNING_DISABLE_PARENTHESES do {} while (0 )
586+ # define WARNING_DISABLE_CONSTANT_COMPARISON do {} while (0 )
583587#endif
584588// clang-format on
585589
@@ -596,31 +600,33 @@ struct with_what_contains : private contains_substring {
596600#define REQUIRE (EXP ) \
597601 do { \
598602 ++CURRENT_CASE.tests ; \
603+ WARNING_PUSH; \
604+ WARNING_DISABLE_PARENTHESES; \
605+ WARNING_DISABLE_CONSTANT_COMPARISON; \
599606 if (!(EXP)) { \
600- WARNING_PUSH; \
601- WARNING_DISABLE_PARENTHESES; \
602607 const auto EXP2 = TESTING_EXPR (EXP); \
603- WARNING_POP; \
604608 snatch::tests.print_failure (); \
605609 snatch::tests.print_location (CURRENT_CASE, __FILE__, __LINE__); \
606610 snatch::tests.print_details_expr (" REQUIRE" , #EXP, EXP2); \
607611 throw snatch::impl::test_state::failed; \
608612 } \
613+ WARNING_POP; \
609614 } while (0 )
610615
611616#define CHECK (EXP ) \
612617 do { \
613618 ++CURRENT_CASE.tests ; \
619+ WARNING_PUSH; \
620+ WARNING_DISABLE_PARENTHESES; \
621+ WARNING_DISABLE_CONSTANT_COMPARISON; \
614622 if (!(EXP)) { \
615- WARNING_PUSH; \
616- WARNING_DISABLE_PARENTHESES; \
617623 const auto EXP2 = TESTING_EXPR (EXP); \
618- WARNING_POP; \
619624 snatch::tests.print_failure (); \
620625 snatch::tests.print_location (CURRENT_CASE, __FILE__, __LINE__); \
621626 snatch::tests.print_details_expr (" CHECK" , #EXP, EXP2); \
622627 snatch::tests.set_state (CURRENT_CASE, snatch::impl::test_state::failed); \
623628 } \
629+ WARNING_POP; \
624630 } while (0 )
625631
626632#define FAIL (MESSAGE ) \
0 commit comments