13 #include "gmock/gmock.h"
21 TEST(UnicharTest, Conversion) {
25 const char* kUTF8Src =
"a\u05d0\u0ca4\U0002a714";
26 const std::vector<char32> kUTF32Src = {
'a', 0x5d0, 0xca4, 0x2a714};
28 std::vector<char32> utf32 = UNICHAR::UTF8ToUTF32(kUTF8Src);
29 EXPECT_THAT(utf32, testing::ElementsAreArray(kUTF32Src));
31 EXPECT_STREQ(kUTF8Src, utf8.c_str());
34 TEST(UnicharTest, InvalidText) {
36 const char* kInvalidUTF8 =
"a b\200d string";
37 const std::vector<char32> kInvalidUTF32 = {
'a',
' ', 0x200000,
'x'};
39 std::vector<char32> utf32 = UNICHAR::UTF8ToUTF32(kInvalidUTF8);
40 EXPECT_TRUE(utf32.empty());
42 std::string utf8 = UNICHAR::UTF32ToUTF8(kInvalidUTF32);
43 EXPECT_TRUE(utf8.empty());