diff options
author | crupest <crupest@outlook.com> | 2020-07-07 22:58:10 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-07-07 22:58:10 +0800 |
commit | 1f6ae975355271bba248204f9930a93a51068f7c (patch) | |
tree | a82fb574589ea95721e711dda6474f9c63c5c820 /test/common | |
parent | 3bf5b1fcf2315a1ce180ad69eb6bb1e57be37ca5 (diff) | |
download | cru-1f6ae975355271bba248204f9930a93a51068f7c.tar.gz cru-1f6ae975355271bba248204f9930a93a51068f7c.tar.bz2 cru-1f6ae975355271bba248204f9930a93a51068f7c.zip |
...
Diffstat (limited to 'test/common')
-rw-r--r-- | test/common/StringUtilTest.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/test/common/StringUtilTest.cpp b/test/common/StringUtilTest.cpp index ba5e9321..351b1923 100644 --- a/test/common/StringUtilTest.cpp +++ b/test/common/StringUtilTest.cpp @@ -41,7 +41,7 @@ TEST(StringUtil, Utf16PreviousCodePoint) { ASSERT_EQ(Utf16PreviousCodePoint(text, current, ¤t), 0x0061); ASSERT_EQ(Utf16PreviousCodePoint(text, current, ¤t), k_invalid_code_point); - ASSERT_EQ(current, 0u); + ASSERT_EQ(current, 0); } TEST(StringUtil, Utf8CodePointIterator) { @@ -74,6 +74,22 @@ TEST(StringUtil, Utf16CodePointIterator) { ASSERT_EQ(code_points, expected_code_points); } +TEST(StringUtil, ToUtf8) { + using cru::ToUtf8; + std::u16string_view utf16_text = u"aπ你🤣!"; + std::string_view utf8_text = "aπ你🤣!"; + + ASSERT_EQ(ToUtf8(utf16_text), utf8_text); +} + +TEST(StringUtil, ToUtf16) { + using cru::ToUtf16; + std::u16string_view utf16_text = u"aπ你🤣!"; + std::string_view utf8_text = "aπ你🤣!"; + + ASSERT_EQ(ToUtf16(utf8_text), utf16_text); +} + // TEST(WinString, IndexUtf8ToUtf16) { // using cru::platform::win::IndexUtf8ToUtf16; // std::string_view utf8_string = "aπ你🤣!"; |