Skip to content

Commit 78a4f6b

Browse files
author
Hana Dusíková
committed
fix test macro
1 parent ef09e83 commit 78a4f6b

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

tests/ci.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@
22

33
#if CTRE_CNTTP_COMPILER_CHECK
44

5-
#define TEST_MATCH(pattern, subject) ctre::match<pattern>(subject)
5+
#define TEST_MATCH(pattern, subject, result) static_assert(ctre::match<pattern, ctre::case_sensitive>(subject) == result)
66

7-
#define TEST_CI_MATCH(pattern, subject) ctre::match<pattern, ctre::case_insensitive>(subject)
7+
#define TEST_CI_MATCH(pattern, subject, result) static_assert(ctre::match<pattern, ctre::case_insensitive>(subject) == result)
88

99
#else
1010

11-
#define TEST_MATCH(pattern, subject) []{ static constexpr inline auto _ptn ## __LINE__ = ctll::fixed_string(pattern); return ctre::re<_ptn ## i__LINE__d, ctre::match_method, ctre::case_insensitive>(subject); }()
11+
#define UNIQUE_ID_HELPER(A,B) A ## B
12+
#define UNIQUE_ID(LINE) UNIQUE_ID_HELPER(_ptn, LINE)
1213

13-
#define TEST_CI_MATCH(pattern, subject) []{ static constexpr inline auto _ptn ## __LINE__ = ctll::fixed_string(pattern); return ctre::re<_ptn ## i__LINE__d, ctre::match_method, ctre::case_insensitive>(subject); }()
14+
#define TEST_MATCH(pattern, subject, result) static constexpr auto UNIQUE_ID(__LINE__) = ctll::fixed_string(pattern); static_assert(ctre::regular_expression<typename ctre::regex_builder<UNIQUE_ID(__LINE__)>::type, ctre::match_method, ctre::case_sensitive>{}(subject) == result)
15+
16+
#define TEST_CI_MATCH(pattern, subject, result) static constexpr auto UNIQUE_ID(__LINE__) = ctll::fixed_string(pattern); static_assert(ctre::regular_expression<typename ctre::regex_builder<UNIQUE_ID(__LINE__)>::type, ctre::match_method, ctre::case_insensitive>{}(subject) == result)
1417

1518
#endif
1619

17-
static_assert(TEST_MATCH("aloha","aloha"));
18-
static_assert(!TEST_MATCH("aloha","ALOHA"));
20+
TEST_MATCH("aloha","aloha", true);
21+
TEST_MATCH("aloha","ALOHA", false);
1922

20-
static_assert(TEST_CI_MATCH("aloha", "aloha"));
21-
static_assert(TEST_CI_MATCH("aloha", "ALOHA"));
23+
TEST_CI_MATCH("aloha", "aloha", true);
24+
TEST_CI_MATCH("aloha", "ALOHA", true);

0 commit comments

Comments
 (0)