Merge "libutils: add unit tests for invalid utf-8 and utf-16 strings" am: eb85221dcf am: c21e63ea26 am: ddc33e4f85
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1470423 Change-Id: Id91f395bb15994cecba80e35f2a97ca3fa4ff831
This commit is contained in:
commit
cc2f1917ac
2 changed files with 17 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -96,4 +96,9 @@ TEST_F(String8Test, CheckUtf32Conversion) {
|
|||
EXPECT_EQ(10U, string8.length());
|
||||
}
|
||||
|
||||
TEST_F(String8Test, ValidUtf16Conversion) {
|
||||
char16_t tmp[] = u"abcdef";
|
||||
String8 valid = String8(String16(tmp));
|
||||
EXPECT_STREQ(valid, "abcdef");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue