|
2 | 2 |
|
3 | 3 | #if CTRE_CNTTP_COMPILER_CHECK |
4 | 4 |
|
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) |
6 | 6 |
|
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) |
8 | 8 |
|
9 | 9 | #else |
10 | 10 |
|
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) |
12 | 13 |
|
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) |
14 | 17 |
|
15 | 18 | #endif |
16 | 19 |
|
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); |
19 | 22 |
|
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