diff options
author | Steven Moreland <smoreland@google.com> | 2020-05-28 00:29:08 +0000 |
---|---|---|
committer | Steven Moreland <smoreland@google.com> | 2020-05-28 00:31:01 +0000 |
commit | f251c1c581f2d1b9940e60e756315c5e15443990 (patch) | |
tree | b919076d3de2bedb553753db0ef3f56aa919f2ac /libutils/String16_test.cpp | |
parent | ddb18842b990d31fe28ac1b901e18d7fde26df35 (diff) |
String16::remove - avoid overflow
Bug: 156999009
Test: libutils_test (cases added)
Change-Id: Iad46d95d9848928ba81000090b2fe9aec1e5eaac
Diffstat (limited to 'libutils/String16_test.cpp')
-rw-r--r-- | libutils/String16_test.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libutils/String16_test.cpp b/libutils/String16_test.cpp index f1f24c394..ae9ba89c7 100644 --- a/libutils/String16_test.cpp +++ b/libutils/String16_test.cpp @@ -90,6 +90,13 @@ TEST(String16Test, Insert) { EXPECT_STR16EQ(u"VerifyInsert me", tmp); } +TEST(String16Test, RemoveDefault) { + String16 tmp("Verify me"); + tmp.remove(4); + EXPECT_EQ(4U, tmp.size()); + EXPECT_STR16EQ(u"Veri", tmp); +} + TEST(String16Test, Remove) { String16 tmp("Verify me"); tmp.remove(2, 6); @@ -97,6 +104,13 @@ TEST(String16Test, Remove) { EXPECT_STR16EQ(u" m", tmp); } +TEST(String16Test, RemoveOutOfBounds) { + String16 tmp("Verify me"); + tmp.remove(100, 6); + EXPECT_EQ(3U, tmp.size()); + EXPECT_STR16EQ(u" me", tmp); +} + TEST(String16Test, MakeLower) { String16 tmp("Verify Me!"); tmp.makeLower(); |