Skip to content

Commit 5cfe317

Browse files
Merge pull request #24 from Bronek/identifiers_fix
Remove names from the context of SOMETIMES_ALL and ALWAYS_SOME
2 parents 10edf7f + 7fea3e4 commit 5cfe317

File tree

1 file changed

+16
-24
lines changed

1 file changed

+16
-24
lines changed

antithesis_sdk.h

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -982,48 +982,40 @@ ANTITHESIS_NUMERIC_ASSERT_RAW(SOMETIMES_LESS_THAN_OR_EQUAL_TO, antithesis::inter
982982

983983
#define ALWAYS_SOME(pairs, message, ...) \
984984
do { \
985-
bool disjunction = false; \
986-
std::vector<std::pair<std::string, bool>> vec_pairs = pairs; \
987-
for (std::pair<std::string, bool> pair : vec_pairs) { \
988-
if (pair.second) { \
989-
disjunction = true; \
990-
break; \
991-
} \
992-
} \
993-
ANTITHESIS_ASSERT_RAW(antithesis::internal::assertions::ALWAYS_ASSERTION, disjunction, message, __VA_ARGS__ __VA_OPT__(,) pairs); \
994-
antithesis::JSON json_pairs = antithesis::JSON(pairs); \
985+
ANTITHESIS_ASSERT_RAW(antithesis::internal::assertions::ALWAYS_ASSERTION, ( \
986+
[](std::initializer_list<std::pair<std::string, bool>> ps){ \
987+
for (auto const& pair : ps) \
988+
if (pair.second) return true; \
989+
return false; }(pairs)), \
990+
message, __VA_ARGS__ __VA_OPT__(,) pairs); \
995991
antithesis::internal::BooleanGuidanceCatalogEntry< \
996-
decltype(json_pairs), \
992+
antithesis::JSON, \
997993
antithesis::internal::assertions::GUIDEPOST_NONE, \
998994
antithesis::internal::fixed_string(message), \
999995
FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \
1000996
FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \
1001997
std::source_location::current().line(), \
1002998
std::source_location::current().column() \
1003-
>::guidepost.send_guidance(json_pairs); \
999+
>::guidepost.send_guidance(antithesis::JSON(pairs)); \
10041000
} while (0)
10051001

10061002
#define SOMETIMES_ALL(pairs, message, ...) \
10071003
do { \
1008-
bool conjunction = true; \
1009-
std::vector<std::pair<std::string, bool>> vec_pairs = pairs; \
1010-
for (std::pair<std::string, bool> pair : vec_pairs) { \
1011-
if (!pair.second) { \
1012-
conjunction = false; \
1013-
break; \
1014-
} \
1015-
} \
1016-
ANTITHESIS_ASSERT_RAW(antithesis::internal::assertions::SOMETIMES_ASSERTION, conjunction, message, __VA_ARGS__ __VA_OPT__(,) pairs); \
1017-
antithesis::JSON json_pairs = antithesis::JSON(pairs); \
1004+
ANTITHESIS_ASSERT_RAW(antithesis::internal::assertions::SOMETIMES_ASSERTION, ( \
1005+
[](std::initializer_list<std::pair<std::string, bool>> ps){ \
1006+
for (auto const& pair : ps) \
1007+
if (!pair.second) return false; \
1008+
return true; }(pairs)), \
1009+
message, __VA_ARGS__ __VA_OPT__(,) pairs); \
10181010
antithesis::internal::BooleanGuidanceCatalogEntry< \
1019-
decltype(json_pairs), \
1011+
antithesis::JSON, \
10201012
antithesis::internal::assertions::GUIDEPOST_ALL, \
10211013
antithesis::internal::fixed_string(message), \
10221014
FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \
10231015
FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \
10241016
std::source_location::current().line(), \
10251017
std::source_location::current().column() \
1026-
>::guidepost.send_guidance(json_pairs); \
1018+
>::guidepost.send_guidance(antithesis::JSON(pairs)); \
10271019
} while (0)
10281020

10291021
#endif

0 commit comments

Comments
 (0)