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

Unified Diff: base/pickle_unittest.cc

Issue 1538743002: Switch to standard integer types in base/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DEPS roll too Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/pickle.cc ('k') | base/posix/safe_strerror.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/pickle_unittest.cc
diff --git a/base/pickle_unittest.cc b/base/pickle_unittest.cc
index 6804614d9fadca6e3c42feb471ea7e04d43b7261..b195a81e5e9ca36d4dc12f17a4e13f58f9815bc6 100644
--- a/base/pickle_unittest.cc
+++ b/base/pickle_unittest.cc
@@ -2,9 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <limits.h>
+#include <stddef.h>
+#include <stdint.h>
+
#include <string>
-#include "base/basictypes.h"
+#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/pickle.h"
#include "base/strings/string16.h"
@@ -19,10 +23,10 @@ const bool testbool1 = false;
const bool testbool2 = true;
const int testint = 2093847192;
const long testlong = 1093847192;
-const uint16 testuint16 = 32123;
-const uint32 testuint32 = 1593847192;
-const int64 testint64 = -0x7E8CA9253104BDFCLL;
-const uint64 testuint64 = 0xCE8CA9253104BDF7ULL;
+const uint16_t testuint16 = 32123;
+const uint32_t testuint32 = 1593847192;
+const int64_t testint64 = -0x7E8CA9253104BDFCLL;
+const uint64_t testuint64 = 0xCE8CA9253104BDF7ULL;
const size_t testsizet = 0xFEDC7654;
const float testfloat = 3.1415926935f;
const double testdouble = 2.71828182845904523;
@@ -53,19 +57,19 @@ void VerifyResult(const Pickle& pickle) {
EXPECT_TRUE(iter.ReadLong(&outlong));
EXPECT_EQ(testlong, outlong);
- uint16 outuint16;
+ uint16_t outuint16;
EXPECT_TRUE(iter.ReadUInt16(&outuint16));
EXPECT_EQ(testuint16, outuint16);
- uint32 outuint32;
+ uint32_t outuint32;
EXPECT_TRUE(iter.ReadUInt32(&outuint32));
EXPECT_EQ(testuint32, outuint32);
- int64 outint64;
+ int64_t outint64;
EXPECT_TRUE(iter.ReadInt64(&outint64));
EXPECT_EQ(testint64, outint64);
- uint64 outuint64;
+ uint64_t outuint64;
EXPECT_TRUE(iter.ReadUInt64(&outuint64));
EXPECT_EQ(testuint64, outuint64);
@@ -147,12 +151,13 @@ TEST(PickleTest, EncodeDecode) {
TEST(PickleTest, SizeTFrom64Bit) {
Pickle pickle;
// Under the hood size_t is always written as a 64-bit value, so simulate a
- // 64-bit size_t even on 32-bit architectures by explicitly writing a uint64.
+ // 64-bit size_t even on 32-bit architectures by explicitly writing a
+ // uint64_t.
EXPECT_TRUE(pickle.WriteUInt64(testuint64));
PickleIterator iter(pickle);
size_t outsizet;
- if (sizeof(size_t) < sizeof(uint64)) {
+ if (sizeof(size_t) < sizeof(uint64_t)) {
// ReadSizeT() should return false when the original written value can't be
// represented as a size_t.
EXPECT_FALSE(iter.ReadSizeT(&outsizet));
@@ -398,10 +403,10 @@ TEST(PickleTest, Resize) {
// construct a message that will be exactly the size of one payload unit,
// note that any data will have a 4-byte header indicating the size
- const size_t payload_size_after_header = unit - sizeof(uint32);
+ const size_t payload_size_after_header = unit - sizeof(uint32_t);
Pickle pickle;
- pickle.WriteData(data_ptr,
- static_cast<int>(payload_size_after_header - sizeof(uint32)));
+ pickle.WriteData(
+ data_ptr, static_cast<int>(payload_size_after_header - sizeof(uint32_t)));
size_t cur_payload = payload_size_after_header;
// note: we assume 'unit' is a power of 2
@@ -409,7 +414,7 @@ TEST(PickleTest, Resize) {
EXPECT_EQ(pickle.payload_size(), payload_size_after_header);
// fill out a full page (noting data header)
- pickle.WriteData(data_ptr, static_cast<int>(unit - sizeof(uint32)));
+ pickle.WriteData(data_ptr, static_cast<int>(unit - sizeof(uint32_t)));
cur_payload += unit;
EXPECT_EQ(unit * 2, pickle.capacity_after_header());
EXPECT_EQ(cur_payload, pickle.payload_size());
@@ -430,7 +435,7 @@ struct CustomHeader : Pickle::Header {
} // namespace
TEST(PickleTest, HeaderPadding) {
- const uint32 kMagic = 0x12345678;
+ const uint32_t kMagic = 0x12345678;
Pickle pickle(sizeof(CustomHeader));
pickle.WriteInt(kMagic);
@@ -442,7 +447,7 @@ TEST(PickleTest, HeaderPadding) {
int result;
ASSERT_TRUE(iter.ReadInt(&result));
- EXPECT_EQ(static_cast<uint32>(result), kMagic);
+ EXPECT_EQ(static_cast<uint32_t>(result), kMagic);
}
TEST(PickleTest, EqualsOperator) {
« no previous file with comments | « base/pickle.cc ('k') | base/posix/safe_strerror.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698