aboutsummaryrefslogtreecommitdiff
path: root/test/win/string.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-12-31 23:24:01 +0800
committercrupest <crupest@outlook.com>2019-12-31 23:24:01 +0800
commit13d84d93e6695184a92cc0b7f85230e7b78d7a96 (patch)
treee60323b65ada0edac2e309235c16e4ae241b92ab /test/win/string.cpp
parented6bab6393d768bd46f0072113edc80b9f33ac75 (diff)
downloadcru-13d84d93e6695184a92cc0b7f85230e7b78d7a96.tar.gz
cru-13d84d93e6695184a92cc0b7f85230e7b78d7a96.tar.bz2
cru-13d84d93e6695184a92cc0b7f85230e7b78d7a96.zip
...
Diffstat (limited to 'test/win/string.cpp')
-rw-r--r--test/win/string.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/test/win/string.cpp b/test/win/string.cpp
index 4e25f8c0..3864b987 100644
--- a/test/win/string.cpp
+++ b/test/win/string.cpp
@@ -4,7 +4,7 @@
using cru::platform::win::k_code_point_end;
-TEST(WinString, Utf8ShouldWork) {
+TEST(WinString, Utf8Iterator) {
using cru::platform::win::Utf8Iterator;
std::string_view text = "aπ你🤣!";
Utf8Iterator i{text};
@@ -16,7 +16,7 @@ TEST(WinString, Utf8ShouldWork) {
ASSERT_EQ(i.Next(), k_code_point_end);
}
-TEST(WinString, Utf16ShouldWork) {
+TEST(WinString, Utf16Iterator) {
using cru::platform::win::Utf16Iterator;
std::wstring_view text = L"aπ你🤣!";
Utf16Iterator i{text};
@@ -28,3 +28,26 @@ TEST(WinString, Utf16ShouldWork) {
ASSERT_EQ(i.Next(), k_code_point_end);
}
+TEST(WinString, IndexUtf8ToUtf16) {
+ using cru::platform::win::IndexUtf8ToUtf16;
+ std::string_view utf8_string = "aπ你🤣!";
+ std::wstring_view utf16_string = L"aπ你🤣!";
+ ASSERT_EQ(IndexUtf8ToUtf16(utf8_string, 0, utf16_string), 0);
+ ASSERT_EQ(IndexUtf8ToUtf16(utf8_string, 1, utf16_string), 1);
+ ASSERT_EQ(IndexUtf8ToUtf16(utf8_string, 3, utf16_string), 2);
+ ASSERT_EQ(IndexUtf8ToUtf16(utf8_string, 6, utf16_string), 3);
+ ASSERT_EQ(IndexUtf8ToUtf16(utf8_string, 10, utf16_string), 5);
+ ASSERT_EQ(IndexUtf8ToUtf16(utf8_string, 11, utf16_string), 6);
+}
+
+TEST(WinString, IndexUtf16ToUtf8) {
+ using cru::platform::win::IndexUtf16ToUtf8;
+ std::string_view utf8_string = "aπ你🤣!";
+ std::wstring_view utf16_string = L"aπ你🤣!";
+ ASSERT_EQ(IndexUtf16ToUtf8(utf16_string, 0, utf8_string), 0);
+ ASSERT_EQ(IndexUtf16ToUtf8(utf16_string, 1, utf8_string), 1);
+ ASSERT_EQ(IndexUtf16ToUtf8(utf16_string, 2, utf8_string), 3);
+ ASSERT_EQ(IndexUtf16ToUtf8(utf16_string, 3, utf8_string), 6);
+ ASSERT_EQ(IndexUtf16ToUtf8(utf16_string, 5, utf8_string), 10);
+ ASSERT_EQ(IndexUtf16ToUtf8(utf16_string, 6, utf8_string), 11);
+}