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

Side by Side Diff: base/strings/string_util_unittest.cc

Issue 1548993002: Switch to standard integer types in base/strings/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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/strings/string_util_posix.h ('k') | base/strings/string_util_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <stddef.h>
10 #include <stdint.h>
9 11
10 #include <algorithm> 12 #include <algorithm>
11 13
12 #include "base/basictypes.h" 14 #include "base/macros.h"
13 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
14 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
15 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
17 19
18 using ::testing::ElementsAre; 20 using ::testing::ElementsAre;
19 21
20 namespace base { 22 namespace base {
21 23
22 static const struct trim_case { 24 static const struct trim_case {
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 for (size_t i = 0; i < arraysize(lowercase_cases); ++i) { 544 for (size_t i = 0; i < arraysize(lowercase_cases); ++i) {
543 EXPECT_TRUE(LowerCaseEqualsASCII(ASCIIToUTF16(lowercase_cases[i].src_a), 545 EXPECT_TRUE(LowerCaseEqualsASCII(ASCIIToUTF16(lowercase_cases[i].src_a),
544 lowercase_cases[i].dst)); 546 lowercase_cases[i].dst));
545 EXPECT_TRUE(LowerCaseEqualsASCII(lowercase_cases[i].src_a, 547 EXPECT_TRUE(LowerCaseEqualsASCII(lowercase_cases[i].src_a,
546 lowercase_cases[i].dst)); 548 lowercase_cases[i].dst));
547 } 549 }
548 } 550 }
549 551
550 TEST(StringUtilTest, FormatBytesUnlocalized) { 552 TEST(StringUtilTest, FormatBytesUnlocalized) {
551 static const struct { 553 static const struct {
552 int64 bytes; 554 int64_t bytes;
553 const char* expected; 555 const char* expected;
554 } cases[] = { 556 } cases[] = {
555 // Expected behavior: we show one post-decimal digit when we have 557 // Expected behavior: we show one post-decimal digit when we have
556 // under two pre-decimal digits, except in cases where it makes no 558 // under two pre-decimal digits, except in cases where it makes no
557 // sense (zero or bytes). 559 // sense (zero or bytes).
558 // Since we switch units once we cross the 1000 mark, this keeps 560 // Since we switch units once we cross the 1000 mark, this keeps
559 // the display of file sizes or bytes consistently around three 561 // the display of file sizes or bytes consistently around three
560 // digits. 562 // digits.
561 {0, "0 B"}, 563 {0, "0 B"},
562 {512, "512 B"}, 564 {512, "512 B"},
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 const std::string live = kLive; 1131 const std::string live = kLive;
1130 std::string dead = live; 1132 std::string dead = live;
1131 strncpy(WriteInto(&dead, 5), kDead, 4); 1133 strncpy(WriteInto(&dead, 5), kDead, 4);
1132 EXPECT_EQ(kDead, dead); 1134 EXPECT_EQ(kDead, dead);
1133 EXPECT_EQ(4u, dead.size()); 1135 EXPECT_EQ(4u, dead.size());
1134 EXPECT_EQ(kLive, live); 1136 EXPECT_EQ(kLive, live);
1135 EXPECT_EQ(4u, live.size()); 1137 EXPECT_EQ(4u, live.size());
1136 } 1138 }
1137 1139
1138 } // namespace base 1140 } // namespace base
OLDNEW
« no previous file with comments | « base/strings/string_util_posix.h ('k') | base/strings/string_util_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698