Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: base/string_split_unittest.cc

Issue 9950039: Revert r12998 - it broke some media/mime-related layout tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/string_split.cc ('k') | chrome/common/extensions/api/extension_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 using ::testing::ElementsAre; 11 using ::testing::ElementsAre;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 SplitStringUsingSubstr("", "DELIMITER", &results); 156 SplitStringUsingSubstr("", "DELIMITER", &results);
157 ASSERT_EQ(1u, results.size()); 157 ASSERT_EQ(1u, results.size());
158 EXPECT_THAT(results, ElementsAre("")); 158 EXPECT_THAT(results, ElementsAre(""));
159 } 159 }
160 160
161 // Test for SplitString 161 // Test for SplitString
162 TEST(StringUtilTest, SplitString) { 162 TEST(StringUtilTest, SplitString) {
163 std::vector<std::wstring> r; 163 std::vector<std::wstring> r;
164 164
165 SplitString(L"", L',', &r); 165 SplitString(L"", L',', &r);
166 EXPECT_EQ(0U, r.size()); 166 ASSERT_EQ(1U, r.size());
167 EXPECT_EQ(r[0], L"");
167 r.clear(); 168 r.clear();
168 169
169 SplitString(L"a,b,c", L',', &r); 170 SplitString(L"a,b,c", L',', &r);
170 ASSERT_EQ(3U, r.size()); 171 ASSERT_EQ(3U, r.size());
171 EXPECT_EQ(r[0], L"a"); 172 EXPECT_EQ(r[0], L"a");
172 EXPECT_EQ(r[1], L"b"); 173 EXPECT_EQ(r[1], L"b");
173 EXPECT_EQ(r[2], L"c"); 174 EXPECT_EQ(r[2], L"c");
174 r.clear(); 175 r.clear();
175 176
176 SplitString(L"a, b, c", L',', &r); 177 SplitString(L"a, b, c", L',', &r);
177 ASSERT_EQ(3U, r.size()); 178 ASSERT_EQ(3U, r.size());
178 EXPECT_EQ(r[0], L"a"); 179 EXPECT_EQ(r[0], L"a");
179 EXPECT_EQ(r[1], L"b"); 180 EXPECT_EQ(r[1], L"b");
180 EXPECT_EQ(r[2], L"c"); 181 EXPECT_EQ(r[2], L"c");
181 r.clear(); 182 r.clear();
182 183
183 SplitString(L"a,,c", L',', &r); 184 SplitString(L"a,,c", L',', &r);
184 ASSERT_EQ(3U, r.size()); 185 ASSERT_EQ(3U, r.size());
185 EXPECT_EQ(r[0], L"a"); 186 EXPECT_EQ(r[0], L"a");
186 EXPECT_EQ(r[1], L""); 187 EXPECT_EQ(r[1], L"");
187 EXPECT_EQ(r[2], L"c"); 188 EXPECT_EQ(r[2], L"c");
188 r.clear(); 189 r.clear();
189 190
190 SplitString(L" ", L'*', &r); 191 SplitString(L"", L'*', &r);
191 EXPECT_EQ(0U, r.size()); 192 ASSERT_EQ(1U, r.size());
193 EXPECT_EQ(r[0], L"");
192 r.clear(); 194 r.clear();
193 195
194 SplitString(L"foo", L'*', &r); 196 SplitString(L"foo", L'*', &r);
195 ASSERT_EQ(1U, r.size()); 197 ASSERT_EQ(1U, r.size());
196 EXPECT_EQ(r[0], L"foo"); 198 EXPECT_EQ(r[0], L"foo");
197 r.clear(); 199 r.clear();
198 200
199 SplitString(L"foo ,", L',', &r); 201 SplitString(L"foo ,", L',', &r);
200 ASSERT_EQ(2U, r.size()); 202 ASSERT_EQ(2U, r.size());
201 EXPECT_EQ(r[0], L"foo"); 203 EXPECT_EQ(r[0], L"foo");
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 "DELIMITER", 259 "DELIMITER",
258 &results); 260 &results);
259 ASSERT_EQ(7u, results.size()); 261 ASSERT_EQ(7u, results.size());
260 EXPECT_THAT( 262 EXPECT_THAT(
261 results, ElementsAre("un", "deux", "trois", "quatre", "", "", "")); 263 results, ElementsAre("un", "deux", "trois", "quatre", "", "", ""));
262 } 264 }
263 265
264 TEST(StringSplitTest, StringSplitDontTrim) { 266 TEST(StringSplitTest, StringSplitDontTrim) {
265 std::vector<std::string> r; 267 std::vector<std::string> r;
266 268
267 SplitStringDontTrim(" ", '*', &r); 269 SplitStringDontTrim("\t\ta\t", '\t', &r);
268 ASSERT_EQ(1U, r.size());
269 EXPECT_EQ(r[0], " ");
270 r.clear();
271
272 SplitStringDontTrim("\t \ta\t ", '\t', &r);
273 ASSERT_EQ(4U, r.size()); 270 ASSERT_EQ(4U, r.size());
274 EXPECT_EQ(r[0], ""); 271 EXPECT_EQ(r[0], "");
275 EXPECT_EQ(r[1], " "); 272 EXPECT_EQ(r[1], "");
276 EXPECT_EQ(r[2], "a"); 273 EXPECT_EQ(r[2], "a");
277 EXPECT_EQ(r[3], " "); 274 EXPECT_EQ(r[3], "");
278 r.clear(); 275 r.clear();
279 276
280 SplitStringDontTrim("\ta\t\nb\tcc", '\n', &r); 277 SplitStringDontTrim("\ta\t\nb\tcc", '\n', &r);
281 ASSERT_EQ(2U, r.size()); 278 ASSERT_EQ(2U, r.size());
282 EXPECT_EQ(r[0], "\ta\t"); 279 EXPECT_EQ(r[0], "\ta\t");
283 EXPECT_EQ(r[1], "b\tcc"); 280 EXPECT_EQ(r[1], "b\tcc");
284 r.clear(); 281 r.clear();
285 } 282 }
286 283
287 TEST(StringSplitTest, SplitStringAlongWhitespace) { 284 TEST(StringSplitTest, SplitStringAlongWhitespace) {
(...skipping 22 matching lines...) Expand all
310 SplitStringAlongWhitespace(data[i].input, &results); 307 SplitStringAlongWhitespace(data[i].input, &results);
311 ASSERT_EQ(data[i].expected_result_count, results.size()); 308 ASSERT_EQ(data[i].expected_result_count, results.size());
312 if (data[i].expected_result_count > 0) 309 if (data[i].expected_result_count > 0)
313 ASSERT_EQ(data[i].output1, results[0]); 310 ASSERT_EQ(data[i].output1, results[0]);
314 if (data[i].expected_result_count > 1) 311 if (data[i].expected_result_count > 1)
315 ASSERT_EQ(data[i].output2, results[1]); 312 ASSERT_EQ(data[i].output2, results[1]);
316 } 313 }
317 } 314 }
318 315
319 } // namespace base 316 } // namespace base
OLDNEW
« no previous file with comments | « base/string_split.cc ('k') | chrome/common/extensions/api/extension_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698