Skip to content

Commit 906b28e

Browse files
Fix tests for unsigned char
The limits of char are architecture dependent, and all modern architectures make it unsigned. Fixes issue 253.
1 parent 029f1f1 commit 906b28e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/generating.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <climits>
12
#include <ctre.hpp>
23

34
void empty_symbol() { }
@@ -52,10 +53,16 @@ static_assert(same_f(CTRE_GEN("(?:abc)"), ctre::string<'a','b','c'>()));
5253
// support for hexdec
5354
static_assert(same_f(CTRE_GEN("\\x40"), ctre::character<char{0x40}>()));
5455
static_assert(same_f(CTRE_GEN("\\x7F"), ctre::character<char{0x7F}>()));
56+
#if CHAR_MAX < 128
5557
// only characters with value < 128 are char otherwise they are internally char32_t
5658
static_assert(same_f(CTRE_GEN("\\x80"), ctre::character<char32_t{0x80}>()));
5759
static_assert(same_f(CTRE_GEN("\\xFF"), ctre::character<char32_t{0xFF}>()));
5860
static_assert(same_f(CTRE_GEN("\\x{FF}"), ctre::character<char32_t{0xFF}>()));
61+
#else
62+
static_assert(same_f(CTRE_GEN("\\x80"), ctre::character<char{0x80}>()));
63+
static_assert(same_f(CTRE_GEN("\\xFF"), ctre::character<char{0xFF}>()));
64+
static_assert(same_f(CTRE_GEN("\\x{FF}"), ctre::character<char{0xFF}>()));
65+
#endif
5966
static_assert(same_f(CTRE_GEN("\\x{FFF}"), ctre::character<char32_t{0xFFF}>()));
6067
static_assert(same_f(CTRE_GEN("\\x{ABCD}"), ctre::character<char32_t{0xABCD}>()));
6168

0 commit comments

Comments
 (0)