summaryrefslogtreecommitdiff
path: root/base/strings_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'base/strings_test.cpp')
-rw-r--r--base/strings_test.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/base/strings_test.cpp b/base/strings_test.cpp
index 9d740947e..ca3c0b83e 100644
--- a/base/strings_test.cpp
+++ b/base/strings_test.cpp
@@ -295,3 +295,19 @@ TEST(strings, EqualsIgnoreCase) {
TEST(strings, ubsan_28729303) {
android::base::Split("/dev/null", ":");
}
+
+TEST(strings, ConsumePrefix) {
+ std::string_view s{"foo.bar"};
+ ASSERT_FALSE(android::base::ConsumePrefix(&s, "bar."));
+ ASSERT_EQ("foo.bar", s);
+ ASSERT_TRUE(android::base::ConsumePrefix(&s, "foo."));
+ ASSERT_EQ("bar", s);
+}
+
+TEST(strings, ConsumeSuffix) {
+ std::string_view s{"foo.bar"};
+ ASSERT_FALSE(android::base::ConsumeSuffix(&s, ".foo"));
+ ASSERT_EQ("foo.bar", s);
+ ASSERT_TRUE(android::base::ConsumeSuffix(&s, ".bar"));
+ ASSERT_EQ("foo", s);
+}