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

Side by Side Diff: base/string_util_unittest.cc

Issue 18659: Simplify HexEncode. (Closed)
Patch Set: Add another test to make sure the shift is correct. 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
« no previous file with comments | « 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 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 std::wstring output; 1448 std::wstring output;
1449 EXPECT_EQ(cases[i].result, 1449 EXPECT_EQ(cases[i].result,
1450 ElideString(cases[i].input, cases[i].max_len, &output)); 1450 ElideString(cases[i].input, cases[i].max_len, &output));
1451 EXPECT_TRUE(output == cases[i].output); 1451 EXPECT_TRUE(output == cases[i].output);
1452 } 1452 }
1453 } 1453 }
1454 1454
1455 TEST(StringUtilTest, HexEncode) { 1455 TEST(StringUtilTest, HexEncode) {
1456 std::string hex(HexEncode(NULL, 0)); 1456 std::string hex(HexEncode(NULL, 0));
1457 EXPECT_EQ(hex.length(), 0U); 1457 EXPECT_EQ(hex.length(), 0U);
1458 unsigned char bytes[] = {0x01, 0xff, 0x02, 0xfe, 0x03}; 1458 unsigned char bytes[] = {0x01, 0xff, 0x02, 0xfe, 0x03, 0x80, 0x81};
1459 hex = HexEncode(bytes, sizeof(bytes)); 1459 hex = HexEncode(bytes, sizeof(bytes));
1460 EXPECT_EQ(hex.compare("01FF02FE03"), 0); 1460 EXPECT_EQ(hex.compare("01FF02FE038081"), 0);
1461 } 1461 }
OLDNEW
« no previous file with comments | « base/string_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698