| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/string_split.h" | 5 #include "base/string_split.h" |
| 6 #include "testing/gmock/include/gmock/gmock.h" | 6 #include "testing/gmock/include/gmock/gmock.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 using ::testing::ElementsAre; | 9 using ::testing::ElementsAre; |
| 10 | 10 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 std::vector<std::string> results; | 170 std::vector<std::string> results; |
| 171 SplitStringUsingSubstr( | 171 SplitStringUsingSubstr( |
| 172 "unDELIMITERdeuxDELIMITERtroisDELIMITERquatreDELIMITERDELIMITERDELIMITER", | 172 "unDELIMITERdeuxDELIMITERtroisDELIMITERquatreDELIMITERDELIMITERDELIMITER", |
| 173 "DELIMITER", | 173 "DELIMITER", |
| 174 &results); | 174 &results); |
| 175 ASSERT_EQ(7u, results.size()); | 175 ASSERT_EQ(7u, results.size()); |
| 176 EXPECT_THAT( | 176 EXPECT_THAT( |
| 177 results, ElementsAre("un", "deux", "trois", "quatre", "", "", "")); | 177 results, ElementsAre("un", "deux", "trois", "quatre", "", "", "")); |
| 178 } | 178 } |
| 179 | 179 |
| 180 TEST(StringSplitTest, StringSplitDontTrim) { |
| 181 std::vector<std::wstring> r; |
| 182 |
| 183 SplitStringDontTrim(L"\t\ta\t", L'\t', &r); |
| 184 ASSERT_EQ(4U, r.size()); |
| 185 EXPECT_EQ(r[0], L""); |
| 186 EXPECT_EQ(r[1], L""); |
| 187 EXPECT_EQ(r[2], L"a"); |
| 188 EXPECT_EQ(r[3], L""); |
| 189 r.clear(); |
| 190 |
| 191 SplitStringDontTrim(L"\ta\t\nb\tcc", L'\n', &r); |
| 192 ASSERT_EQ(2U, r.size()); |
| 193 EXPECT_EQ(r[0], L"\ta\t"); |
| 194 EXPECT_EQ(r[1], L"b\tcc"); |
| 195 r.clear(); |
| 196 } |
| 197 |
| 180 } // namespace base | 198 } // namespace base |
| OLD | NEW |