Skip to content

Commit 6b344bf

Browse files
committed
fixes #253: test didn't account with signed char type architectures
1 parent e34c26b commit 6b344bf

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/generating.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ static_assert(same_f(CTRE_GEN("(?:abc)"), ctre::string<'a','b','c'>()));
5353
static_assert(same_f(CTRE_GEN("\\x40"), ctre::character<char{0x40}>()));
5454
static_assert(same_f(CTRE_GEN("\\x7F"), ctre::character<char{0x7F}>()));
5555
// only characters with value < 128 are char otherwise they are internally char32_t
56-
static_assert(same_f(CTRE_GEN("\\x80"), ctre::character<char32_t{0x80}>()));
57-
static_assert(same_f(CTRE_GEN("\\xFF"), ctre::character<char32_t{0xFF}>()));
58-
static_assert(same_f(CTRE_GEN("\\x{FF}"), ctre::character<char32_t{0xFF}>()));
56+
constexpr bool char_is_unsigned = (std::numeric_limits<char>::max)() == 255;
57+
// I wish I could have operator implication here :(
58+
using expected_type = std::conditional_t<char_is_unsigned, char, char32_t>;
59+
static_assert(same_f(CTRE_GEN("\\x80"), ctre::character<expected_type{0x80}>()));
60+
static_assert(same_f(CTRE_GEN("\\xFF"), ctre::character<expected_type{0xFF}>()));
61+
static_assert(same_f(CTRE_GEN("\\x{FF}"), ctre::character<expected_type{0xFF}>()));
62+
5963
static_assert(same_f(CTRE_GEN("\\x{FFF}"), ctre::character<char32_t{0xFFF}>()));
6064
static_assert(same_f(CTRE_GEN("\\x{ABCD}"), ctre::character<char32_t{0xABCD}>()));
6165

0 commit comments

Comments
 (0)