diff --git a/src/tests/unicode.cc b/src/tests/unicode.cc index 2c670ed..7b83d8d 100644 --- a/src/tests/unicode.cc +++ b/src/tests/unicode.cc @@ -4,6 +4,16 @@ using namespace boost::ut; using namespace std::string_view_literals; +void test_encoding( + u32 rune, + std::string_view expected, + reflection::source_location sl = reflection::source_location::current()) +{ + std::stringstream ss; + ss << utf8::Print{rune}; + expect(eq(ss.str(), expected), sl); +} + suite utf8_test = [] { "UTF-8 Character length"_test = [] { expect(utf8::length(" ") == 1_u); @@ -18,4 +28,11 @@ suite utf8_test = [] { expect(eq(utf8::decode("\u2705").first, 0x2705u)); expect(eq(utf8::decode("\U000132d1").first, 0x132d1u)); }; + + "UTF-8 Character encoding"_test = [] { + test_encoding(0x20u, " "); + test_encoding(0x105u, "ą"); + test_encoding(0x2705u, "\u2705"); + test_encoding(0x132d1u, "\U000132d1"); + }; };