| 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 std::string string_with_nul(chars_with_nul, length_with_nul); | 565 std::string string_with_nul(chars_with_nul, length_with_nul); |
| 566 std::wstring wide_with_nul = ASCIIToWide(string_with_nul); | 566 std::wstring wide_with_nul = ASCIIToWide(string_with_nul); |
| 567 EXPECT_EQ(static_cast<std::wstring::size_type>(length_with_nul), | 567 EXPECT_EQ(static_cast<std::wstring::size_type>(length_with_nul), |
| 568 wide_with_nul.length()); | 568 wide_with_nul.length()); |
| 569 std::string narrow_with_nul = WideToASCII(wide_with_nul); | 569 std::string narrow_with_nul = WideToASCII(wide_with_nul); |
| 570 EXPECT_EQ(static_cast<std::string::size_type>(length_with_nul), | 570 EXPECT_EQ(static_cast<std::string::size_type>(length_with_nul), |
| 571 narrow_with_nul.length()); | 571 narrow_with_nul.length()); |
| 572 EXPECT_EQ(0, string_with_nul.compare(narrow_with_nul)); | 572 EXPECT_EQ(0, string_with_nul.compare(narrow_with_nul)); |
| 573 } | 573 } |
| 574 | 574 |
| 575 TEST(StringUtilTest, ToUpperASCII) { |
| 576 EXPECT_EQ('C', ToUpperASCII('C')); |
| 577 EXPECT_EQ('C', ToUpperASCII('c')); |
| 578 EXPECT_EQ('2', ToUpperASCII('2')); |
| 579 |
| 580 EXPECT_EQ(L'C', ToUpperASCII(L'C')); |
| 581 EXPECT_EQ(L'C', ToUpperASCII(L'c')); |
| 582 EXPECT_EQ(L'2', ToUpperASCII(L'2')); |
| 583 |
| 584 std::string in_place_a("Cc2"); |
| 585 StringToUpperASCII(&in_place_a); |
| 586 EXPECT_EQ("CC2", in_place_a); |
| 587 |
| 588 std::wstring in_place_w(L"Cc2"); |
| 589 StringToUpperASCII(&in_place_w); |
| 590 EXPECT_EQ(L"CC2", in_place_w); |
| 591 |
| 592 std::string original_a("Cc2"); |
| 593 std::string upper_a = StringToUpperASCII(original_a); |
| 594 EXPECT_EQ("CC2", upper_a); |
| 595 |
| 596 std::wstring original_w(L"Cc2"); |
| 597 std::wstring upper_w = StringToUpperASCII(original_w); |
| 598 EXPECT_EQ(L"CC2", upper_w); |
| 599 } |
| 600 |
| 575 static const struct { | 601 static const struct { |
| 576 const wchar_t* src_w; | 602 const wchar_t* src_w; |
| 577 const char* src_a; | 603 const char* src_a; |
| 578 const char* dst; | 604 const char* dst; |
| 579 } lowercase_cases[] = { | 605 } lowercase_cases[] = { |
| 580 {L"FoO", "FoO", "foo"}, | 606 {L"FoO", "FoO", "foo"}, |
| 581 {L"foo", "foo", "foo"}, | 607 {L"foo", "foo", "foo"}, |
| 582 {L"FOO", "FOO", "foo"}, | 608 {L"FOO", "FOO", "foo"}, |
| 583 }; | 609 }; |
| 584 | 610 |
| (...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 } | 1548 } |
| 1523 } | 1549 } |
| 1524 | 1550 |
| 1525 TEST(StringUtilTest, HexEncode) { | 1551 TEST(StringUtilTest, HexEncode) { |
| 1526 std::string hex(HexEncode(NULL, 0)); | 1552 std::string hex(HexEncode(NULL, 0)); |
| 1527 EXPECT_EQ(hex.length(), 0U); | 1553 EXPECT_EQ(hex.length(), 0U); |
| 1528 unsigned char bytes[] = {0x01, 0xff, 0x02, 0xfe, 0x03, 0x80, 0x81}; | 1554 unsigned char bytes[] = {0x01, 0xff, 0x02, 0xfe, 0x03, 0x80, 0x81}; |
| 1529 hex = HexEncode(bytes, sizeof(bytes)); | 1555 hex = HexEncode(bytes, sizeof(bytes)); |
| 1530 EXPECT_EQ(hex.compare("01FF02FE038081"), 0); | 1556 EXPECT_EQ(hex.compare("01FF02FE038081"), 0); |
| 1531 } | 1557 } |
| OLD | NEW |