diff options
author | Devin Moore <devinmoore@google.com> | 2020-11-12 17:47:51 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-11-12 17:47:51 +0000 |
commit | 5f9490712b1633be47f77278c918652ec6ea72f3 (patch) | |
tree | c622fb9296f48823795d85c6a062eec2432563e6 /libutils/String16_test.cpp | |
parent | 467db2cbeb5b35db2555c25f001f615d8a4db2d1 (diff) | |
parent | cc2f1917ace9b388171b241b575b9a0d3e3b1cf7 (diff) |
Merge "libutils: add unit tests for invalid utf-8 and utf-16 strings" am: eb85221dcf am: c21e63ea26 am: ddc33e4f85 am: cc2f1917ac
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1470423
Change-Id: Ie9f981fb869868a3acc2ca60e1a1a727b0905ad5
Diffstat (limited to 'libutils/String16_test.cpp')
-rw-r--r-- | libutils/String16_test.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libutils/String16_test.cpp b/libutils/String16_test.cpp index ae9ba89c7..9e02b7886 100644 --- a/libutils/String16_test.cpp +++ b/libutils/String16_test.cpp @@ -229,4 +229,16 @@ TEST(String16Test, EmptyStringIsStatic) { EXPECT_TRUE(tmp.isStaticString()); } +TEST(String16Test, OverreadUtf8Conversion) { + char tmp[] = {'a', static_cast<char>(0xe0), '\0'}; + String16 another(tmp); + EXPECT_TRUE(another.size() == 0); +} + +TEST(String16Test, ValidUtf8Conversion) { + String16 another("abcdef"); + EXPECT_EQ(6U, another.size()); + EXPECT_STR16EQ(another, u"abcdef"); +} + } // namespace android |