OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |