20 #include "gtest/gtest.h" 25 #if !defined(__cpp_char8_t) 26 #if defined(__clang__) 27 #pragma clang diagnostic push 28 #pragma clang diagnostic ignored "-Wc++2a-compat" 31 std::pair<char32_t, std::string> tests[] = {{0x0030, u8
"\u0030"},
33 {0x00010000, u8
"\U00010000"},
34 {0x0000FFFF, u8
"\U0000FFFF"},
35 {0x0010FFFD, u8
"\U0010FFFD"}};
36 for (
auto &test : tests) {
37 char buf0[7] = {
'\x00',
'\x00',
'\x00',
'\x00',
'\x00',
'\x00',
'\x00'};
38 char buf1[7] = {
'\xFF',
'\xFF',
'\xFF',
'\xFF',
'\xFF',
'\xFF',
'\xFF'};
43 int apparent_length = 7;
44 while (buf0[apparent_length - 1] ==
'\x00' &&
45 buf1[apparent_length - 1] ==
'\xFF') {
46 if (--apparent_length == 0)
break;
48 EXPECT_EQ(apparent_length, buf0_written - buf0);
49 EXPECT_EQ(apparent_length, buf1_written - buf1);
50 EXPECT_EQ(apparent_length, test.second.length());
51 EXPECT_EQ(std::string(buf0, apparent_length), test.second);
52 EXPECT_EQ(std::string(buf1, apparent_length), test.second);
54 char buf[32] =
"Don't Tread On Me";
57 char buf2[32] =
"Negative is invalid but sane";
61 #if defined(__clang__) 62 #pragma clang diagnostic pop 64 #endif // !defined(__cpp_char8_t)
size_t EncodeUTF8Char(char *buffer, char32_t utf8_char)
TEST(Symbolize, Unimplemented)