aboutsummaryrefslogtreecommitdiff
path: root/test/common
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-07-07 22:58:10 +0800
committercrupest <crupest@outlook.com>2020-07-07 22:58:10 +0800
commit1f6ae975355271bba248204f9930a93a51068f7c (patch)
treea82fb574589ea95721e711dda6474f9c63c5c820 /test/common
parent3bf5b1fcf2315a1ce180ad69eb6bb1e57be37ca5 (diff)
downloadcru-1f6ae975355271bba248204f9930a93a51068f7c.tar.gz
cru-1f6ae975355271bba248204f9930a93a51068f7c.tar.bz2
cru-1f6ae975355271bba248204f9930a93a51068f7c.zip
...
Diffstat (limited to 'test/common')
-rw-r--r--test/common/StringUtilTest.cpp18
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, &current), 0x0061);
ASSERT_EQ(Utf16PreviousCodePoint(text, current, &current),
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π你🤣!";