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

Side by Side Diff: base/string_split_unittest.cc

Issue 6930047: wstring: remove wstring version of SplitString (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright Created 9 years, 7 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') | no next file » | 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) 2010 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
7 #include "base/utf_string_conversions.h"
6 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
7 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
8 10
9 using ::testing::ElementsAre; 11 using ::testing::ElementsAre;
10 12
11 namespace base { 13 namespace base {
12 14
15 namespace {
Evan Martin 2011/05/05 20:52:24 Not sure about this; I think the test had the abov
brettw 2011/05/05 21:09:41 I normally put the tests in the base namespace sin
16
17 #if !defined(WCHAR_T_IS_UTF16)
18 // Overload SplitString with a wide-char version to make it easier to
19 // test the string16 version with wide character literals.
20 void SplitString(const std::wstring& str,
21 wchar_t c,
22 std::vector<std::wstring>* result) {
23 std::vector<string16> result16;
24 SplitString(WideToUTF16(str), c, &result16);
25 for (size_t i = 0; i < result16.size(); ++i)
26 result->push_back(UTF16ToWide(result16[i]));
27 }
28 #endif
29
13 class SplitStringIntoKeyValuesTest : public testing::Test { 30 class SplitStringIntoKeyValuesTest : public testing::Test {
14 protected: 31 protected:
15 std::string key; 32 std::string key;
16 std::vector<std::string> values; 33 std::vector<std::string> values;
17 }; 34 };
18 35
19 TEST_F(SplitStringIntoKeyValuesTest, EmptyInputMultipleValues) { 36 TEST_F(SplitStringIntoKeyValuesTest, EmptyInputMultipleValues) {
20 EXPECT_FALSE(SplitStringIntoKeyValues("", // Empty input 37 EXPECT_FALSE(SplitStringIntoKeyValues("", // Empty input
21 '\t', // Key separators 38 '\t', // Key separators
22 &key, &values)); 39 &key, &values));
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 std::vector<std::wstring> results; 304 std::vector<std::wstring> results;
288 SplitStringAlongWhitespace(data[i].input, &results); 305 SplitStringAlongWhitespace(data[i].input, &results);
289 ASSERT_EQ(data[i].expected_result_count, results.size()); 306 ASSERT_EQ(data[i].expected_result_count, results.size());
290 if (data[i].expected_result_count > 0) 307 if (data[i].expected_result_count > 0)
291 ASSERT_EQ(data[i].output1, results[0]); 308 ASSERT_EQ(data[i].output1, results[0]);
292 if (data[i].expected_result_count > 1) 309 if (data[i].expected_result_count > 1)
293 ASSERT_EQ(data[i].output2, results[1]); 310 ASSERT_EQ(data[i].output2, results[1]);
294 } 311 }
295 } 312 }
296 313
314 } // namespace
315
297 } // namespace base 316 } // namespace base
OLDNEW
« no previous file with comments | « base/string_split.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698