diff options
Diffstat (limited to 'absl/strings/str_split_test.cc')
-rw-r--r-- | absl/strings/str_split_test.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/absl/strings/str_split_test.cc b/absl/strings/str_split_test.cc index 9c79d7dcd0bf..500f3cbc3789 100644 --- a/absl/strings/str_split_test.cc +++ b/absl/strings/str_split_test.cc @@ -166,6 +166,18 @@ TEST(Split, APIExamples) { } { + // Different forms of initialization / conversion. + std::vector<std::string> v1 = absl::StrSplit("a,b,c", ','); + EXPECT_THAT(v1, ElementsAre("a", "b", "c")); + std::vector<std::string> v2(absl::StrSplit("a,b,c", ',')); + EXPECT_THAT(v2, ElementsAre("a", "b", "c")); + auto v3 = std::vector<std::string>(absl::StrSplit("a,b,c", ',')); + EXPECT_THAT(v3, ElementsAre("a", "b", "c")); + v3 = absl::StrSplit("a,b,c", ','); + EXPECT_THAT(v3, ElementsAre("a", "b", "c")); + } + + { // Results stored in a std::map. std::map<std::string, std::string> m = absl::StrSplit("a,1,b,2,a,3", ','); EXPECT_EQ(2, m.size()); |