summaryrefslogtreecommitdiff
path: root/libutils/String16_test.cpp
diff options
context:
space:
mode:
authorDevin Moore <devinmoore@google.com>2020-11-12 16:46:55 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-11-12 16:46:55 +0000
commitddc33e4f855d948f6245383d8bd70ac5d3addc93 (patch)
tree5b4bd5534822a2b7ae85b75765532fb5b020c24e /libutils/String16_test.cpp
parent6c16ad67365892390a4dd72aab820513a32cba5f (diff)
parentc21e63ea26e145ca5228f0f75b0a6a0a71d012bd (diff)
Merge "libutils: add unit tests for invalid utf-8 and utf-16 strings" am: eb85221dcf am: c21e63ea26
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1470423 Change-Id: Ief9d7c4fe860df98b40f977b7814242d38dfd435
Diffstat (limited to 'libutils/String16_test.cpp')
-rw-r--r--libutils/String16_test.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/libutils/String16_test.cpp b/libutils/String16_test.cpp
index f1f24c394..2505f445d 100644
--- a/libutils/String16_test.cpp
+++ b/libutils/String16_test.cpp
@@ -215,4 +215,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