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

Side by Side Diff: base/string_split_unittest.cc

Issue 8008003: wstring: remove SplitStringAlongWhitespace for wchar (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 9 years, 3 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/browser/themes/theme_service.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) 2011 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
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 276
277 SplitStringDontTrim("\ta\t\nb\tcc", '\n', &r); 277 SplitStringDontTrim("\ta\t\nb\tcc", '\n', &r);
278 ASSERT_EQ(2U, r.size()); 278 ASSERT_EQ(2U, r.size());
279 EXPECT_EQ(r[0], "\ta\t"); 279 EXPECT_EQ(r[0], "\ta\t");
280 EXPECT_EQ(r[1], "b\tcc"); 280 EXPECT_EQ(r[1], "b\tcc");
281 r.clear(); 281 r.clear();
282 } 282 }
283 283
284 TEST(StringSplitTest, SplitStringAlongWhitespace) { 284 TEST(StringSplitTest, SplitStringAlongWhitespace) {
285 struct TestData { 285 struct TestData {
286 const std::wstring input; 286 const char* input;
287 const size_t expected_result_count; 287 const size_t expected_result_count;
288 const std::wstring output1; 288 const char* output1;
289 const std::wstring output2; 289 const char* output2;
290 } data[] = { 290 } data[] = {
291 { L"a", 1, L"a", L"" }, 291 { "a", 1, "a", "" },
292 { L" ", 0, L"", L"" }, 292 { " ", 0, "", "" },
293 { L" a", 1, L"a", L"" }, 293 { " a", 1, "a", "" },
294 { L" ab ", 1, L"ab", L"" }, 294 { " ab ", 1, "ab", "" },
295 { L" ab c", 2, L"ab", L"c" }, 295 { " ab c", 2, "ab", "c" },
296 { L" ab c ", 2, L"ab", L"c" }, 296 { " ab c ", 2, "ab", "c" },
297 { L" ab cd", 2, L"ab", L"cd" }, 297 { " ab cd", 2, "ab", "cd" },
298 { L" ab cd ", 2, L"ab", L"cd" }, 298 { " ab cd ", 2, "ab", "cd" },
299 { L" \ta\t", 1, L"a", L"" }, 299 { " \ta\t", 1, "a", "" },
300 { L" b\ta\t", 2, L"b", L"a" }, 300 { " b\ta\t", 2, "b", "a" },
301 { L" b\tat", 2, L"b", L"at" }, 301 { " b\tat", 2, "b", "at" },
302 { L"b\tat", 2, L"b", L"at" }, 302 { "b\tat", 2, "b", "at" },
303 { L"b\t at", 2, L"b", L"at" }, 303 { "b\t at", 2, "b", "at" },
304 }; 304 };
305 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { 305 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
306 std::vector<std::wstring> results; 306 std::vector<std::string> results;
307 SplitStringAlongWhitespace(data[i].input, &results); 307 SplitStringAlongWhitespace(data[i].input, &results);
308 ASSERT_EQ(data[i].expected_result_count, results.size()); 308 ASSERT_EQ(data[i].expected_result_count, results.size());
309 if (data[i].expected_result_count > 0) 309 if (data[i].expected_result_count > 0)
310 ASSERT_EQ(data[i].output1, results[0]); 310 ASSERT_EQ(data[i].output1, results[0]);
311 if (data[i].expected_result_count > 1) 311 if (data[i].expected_result_count > 1)
312 ASSERT_EQ(data[i].output2, results[1]); 312 ASSERT_EQ(data[i].output2, results[1]);
313 } 313 }
314 } 314 }
315 315
316 } // namespace base 316 } // namespace base
OLDNEW
« no previous file with comments | « base/string_split.cc ('k') | chrome/browser/themes/theme_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698