summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorTom Cherry2017-10-26 12:50:20 -0500
committerTom Cherry2017-10-26 12:50:20 -0500
commitfbbf27da028964d3057382b4aa305cf785173777 (patch)
treeb9177161992c91930080ae9c8acaac6607a6334c /base
parent1c65e77e6d73b9eee13d913e0b7886c72282e67f (diff)
downloadplatform-system-core-fbbf27da028964d3057382b4aa305cf785173777.tar.gz
platform-system-core-fbbf27da028964d3057382b4aa305cf785173777.tar.xz
platform-system-core-fbbf27da028964d3057382b4aa305cf785173777.zip
Add test for android::base::Split with a trailing empty part.
Test: this new unit test Change-Id: Ia14ba878f2866e333a69f1e6f7f56b66a7e657a5
Diffstat (limited to 'base')
-rw-r--r--base/strings_test.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/base/strings_test.cpp b/base/strings_test.cpp
index 7ed5b2b08..121197cab 100644
--- a/base/strings_test.cpp
+++ b/base/strings_test.cpp
@@ -51,6 +51,14 @@ TEST(strings, split_with_empty_part) {
51 ASSERT_EQ("bar", parts[2]); 51 ASSERT_EQ("bar", parts[2]);
52} 52}
53 53
54TEST(strings, split_with_trailing_empty_part) {
55 std::vector<std::string> parts = android::base::Split("foo,bar,", ",");
56 ASSERT_EQ(3U, parts.size());
57 ASSERT_EQ("foo", parts[0]);
58 ASSERT_EQ("bar", parts[1]);
59 ASSERT_EQ("", parts[2]);
60}
61
54TEST(strings, split_null_char) { 62TEST(strings, split_null_char) {
55 std::vector<std::string> parts = 63 std::vector<std::string> parts =
56 android::base::Split(std::string("foo\0bar", 7), std::string("\0", 1)); 64 android::base::Split(std::string("foo\0bar", 7), std::string("\0", 1));