OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/strings/string_util.h" | 5 #include "base/strings/string_util.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <stdarg.h> | 8 #include <stdarg.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 | 587 |
588 // Verify the lower case as well. | 588 // Verify the lower case as well. |
589 EXPECT_EQ(10, HexDigitToInt('a')); | 589 EXPECT_EQ(10, HexDigitToInt('a')); |
590 EXPECT_EQ(11, HexDigitToInt('b')); | 590 EXPECT_EQ(11, HexDigitToInt('b')); |
591 EXPECT_EQ(12, HexDigitToInt('c')); | 591 EXPECT_EQ(12, HexDigitToInt('c')); |
592 EXPECT_EQ(13, HexDigitToInt('d')); | 592 EXPECT_EQ(13, HexDigitToInt('d')); |
593 EXPECT_EQ(14, HexDigitToInt('e')); | 593 EXPECT_EQ(14, HexDigitToInt('e')); |
594 EXPECT_EQ(15, HexDigitToInt('f')); | 594 EXPECT_EQ(15, HexDigitToInt('f')); |
595 } | 595 } |
596 | 596 |
| 597 TEST(StringUtilTest, HigherCaseHexNumber) { |
| 598 EXPECT_TRUE(IsHigherCaseHexNumber("1234567890")); |
| 599 EXPECT_TRUE(IsHigherCaseHexNumber("ABDCEF")); |
| 600 EXPECT_TRUE(IsHigherCaseHexNumber("1A2B3C")); |
| 601 |
| 602 EXPECT_FALSE(IsHigherCaseHexNumber("")); |
| 603 EXPECT_FALSE(IsHigherCaseHexNumber("1a2b3c")); |
| 604 EXPECT_FALSE(IsHigherCaseHexNumber("abcdef")); |
| 605 EXPECT_FALSE(IsHigherCaseHexNumber("GHIJKL")); |
| 606 EXPECT_FALSE(IsHigherCaseHexNumber("!@#$^&*|")); |
| 607 } |
| 608 |
597 // This checks where we can use the assignment operator for a va_list. We need | 609 // This checks where we can use the assignment operator for a va_list. We need |
598 // a way to do this since Visual C doesn't support va_copy, but assignment on | 610 // a way to do this since Visual C doesn't support va_copy, but assignment on |
599 // va_list is not guaranteed to be a copy. See StringAppendVT which uses this | 611 // va_list is not guaranteed to be a copy. See StringAppendVT which uses this |
600 // capability. | 612 // capability. |
601 static void VariableArgsFunc(const char* format, ...) { | 613 static void VariableArgsFunc(const char* format, ...) { |
602 va_list org; | 614 va_list org; |
603 va_start(org, format); | 615 va_start(org, format); |
604 | 616 |
605 va_list dup; | 617 va_list dup; |
606 GG_VA_COPY(dup, org); | 618 GG_VA_COPY(dup, org); |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 const std::string live = kLive; | 1201 const std::string live = kLive; |
1190 std::string dead = live; | 1202 std::string dead = live; |
1191 strncpy(WriteInto(&dead, 5), kDead, 4); | 1203 strncpy(WriteInto(&dead, 5), kDead, 4); |
1192 EXPECT_EQ(kDead, dead); | 1204 EXPECT_EQ(kDead, dead); |
1193 EXPECT_EQ(4u, dead.size()); | 1205 EXPECT_EQ(4u, dead.size()); |
1194 EXPECT_EQ(kLive, live); | 1206 EXPECT_EQ(kLive, live); |
1195 EXPECT_EQ(4u, live.size()); | 1207 EXPECT_EQ(4u, live.size()); |
1196 } | 1208 } |
1197 | 1209 |
1198 } // namespace base | 1210 } // namespace base |
OLD | NEW |