Add test for android::base::Split with a trailing empty part.
Test: this new unit test
Change-Id: Ia14ba878f2866e333a69f1e6f7f56b66a7e657a5
diff --git a/strings_test.cpp b/strings_test.cpp
index 7ed5b2b..121197c 100644
--- a/strings_test.cpp
+++ b/strings_test.cpp
@@ -51,6 +51,14 @@
ASSERT_EQ("bar", parts[2]);
}
+TEST(strings, split_with_trailing_empty_part) {
+ std::vector<std::string> parts = android::base::Split("foo,bar,", ",");
+ ASSERT_EQ(3U, parts.size());
+ ASSERT_EQ("foo", parts[0]);
+ ASSERT_EQ("bar", parts[1]);
+ ASSERT_EQ("", parts[2]);
+}
+
TEST(strings, split_null_char) {
std::vector<std::string> parts =
android::base::Split(std::string("foo\0bar", 7), std::string("\0", 1));