From 1f6ae975355271bba248204f9930a93a51068f7c Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 7 Jul 2020 22:58:10 +0800 Subject: ... --- test/common/StringUtilTest.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'test/common/StringUtilTest.cpp') 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π你🤣!"; -- cgit v1.2.3