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

Side by Side Diff: base/string_util_unittest.cc

Issue 18452: Adding a HexEncode function to string_utils.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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
« base/string_util.cc ('K') | « base/string_util.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <math.h> 5 #include <math.h>
6 #include <stdarg.h> 6 #include <stdarg.h>
7 7
8 #include <limits> 8 #include <limits>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 { L"Hello, my name is Tom", 10, true, L"Hell...Tom" }, 1415 { L"Hello, my name is Tom", 10, true, L"Hell...Tom" },
1416 { L"Hello, my name is Tom", 100, false, L"Hello, my name is Tom" } 1416 { L"Hello, my name is Tom", 100, false, L"Hello, my name is Tom" }
1417 }; 1417 };
1418 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 1418 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
1419 std::wstring output; 1419 std::wstring output;
1420 EXPECT_EQ(cases[i].result, 1420 EXPECT_EQ(cases[i].result,
1421 ElideString(cases[i].input, cases[i].max_len, &output)); 1421 ElideString(cases[i].input, cases[i].max_len, &output));
1422 EXPECT_TRUE(output == cases[i].output); 1422 EXPECT_TRUE(output == cases[i].output);
1423 } 1423 }
1424 } 1424 }
1425
1426 TEST(StringUtilTest, HexEncode) {
1427 std::string hex(HexEncode(NULL, 0));
1428 EXPECT_EQ(hex.length(), 0U);
1429 unsigned char bytes[] = {0x01, 0xff, 0x02, 0xfe, 0x03};
1430 hex = HexEncode(bytes, sizeof(bytes));
1431 EXPECT_EQ(hex.compare("01FF02FE03"), 0);
1432 }
OLDNEW
« base/string_util.cc ('K') | « base/string_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698