summaryrefslogtreecommitdiffstats
path: root/dbus/values_util_unittest.cc
diff options
context:
space:
mode:
authoravi <avi@chromium.org>2015-12-22 10:12:45 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-22 18:13:52 +0000
commit22437c690d92b7440913d190bf5474785ccd73ec (patch)
tree76dbcdd2610bc4deb60e3d4954a14c4d1abc9ff6 /dbus/values_util_unittest.cc
parent73a178bda739c022e3d2ecd79f1c2c1e3e574aa6 (diff)
downloadchromium_src-22437c690d92b7440913d190bf5474785ccd73ec.zip
chromium_src-22437c690d92b7440913d190bf5474785ccd73ec.tar.gz
chromium_src-22437c690d92b7440913d190bf5474785ccd73ec.tar.bz2
Switch to standard integer types in dbus/.
BUG=138542 TBR=hashimoto@chromium.org Review URL: https://codereview.chromium.org/1541193002 Cr-Commit-Position: refs/heads/master@{#366617}
Diffstat (limited to 'dbus/values_util_unittest.cc')
-rw-r--r--dbus/values_util_unittest.cc70
1 files changed, 37 insertions, 33 deletions
diff --git a/dbus/values_util_unittest.cc b/dbus/values_util_unittest.cc
index 6abc56a..b2f1404 100644
--- a/dbus/values_util_unittest.cc
+++ b/dbus/values_util_unittest.cc
@@ -4,10 +4,14 @@
#include "dbus/values_util.h"
+#include <stddef.h>
+#include <stdint.h>
+
#include <cmath>
#include <vector>
#include "base/json/json_writer.h"
+#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "dbus/message.h"
@@ -19,21 +23,21 @@ TEST(ValuesUtilTest, PopBasicTypes) {
scoped_ptr<Response> response(Response::CreateEmpty());
// Append basic type values.
MessageWriter writer(response.get());
- const uint8 kByteValue = 42;
+ const uint8_t kByteValue = 42;
writer.AppendByte(kByteValue);
const bool kBoolValue = true;
writer.AppendBool(kBoolValue);
- const int16 kInt16Value = -43;
+ const int16_t kInt16Value = -43;
writer.AppendInt16(kInt16Value);
- const uint16 kUint16Value = 44;
+ const uint16_t kUint16Value = 44;
writer.AppendUint16(kUint16Value);
- const int32 kInt32Value = -45;
+ const int32_t kInt32Value = -45;
writer.AppendInt32(kInt32Value);
- const uint32 kUint32Value = 46;
+ const uint32_t kUint32Value = 46;
writer.AppendUint32(kUint32Value);
- const int64 kInt64Value = -47;
+ const int64_t kInt64Value = -47;
writer.AppendInt64(kInt64Value);
- const uint64 kUint64Value = 48;
+ const uint64_t kUint64Value = 48;
writer.AppendUint64(kUint64Value);
const double kDoubleValue = 4.9;
writer.AppendDouble(kDoubleValue);
@@ -57,34 +61,34 @@ TEST(ValuesUtilTest, PopBasicTypes) {
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::FundamentalValue(kBoolValue));
EXPECT_TRUE(value->Equals(expected_value.get()));
- // Pop an int16.
+ // Pop an int16_t.
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::FundamentalValue(kInt16Value));
EXPECT_TRUE(value->Equals(expected_value.get()));
- // Pop a uint16.
+ // Pop a uint16_t.
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::FundamentalValue(kUint16Value));
EXPECT_TRUE(value->Equals(expected_value.get()));
- // Pop an int32.
+ // Pop an int32_t.
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::FundamentalValue(kInt32Value));
EXPECT_TRUE(value->Equals(expected_value.get()));
- // Pop a uint32.
+ // Pop a uint32_t.
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(
new base::FundamentalValue(static_cast<double>(kUint32Value)));
EXPECT_TRUE(value->Equals(expected_value.get()));
- // Pop an int64.
+ // Pop an int64_t.
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(
new base::FundamentalValue(static_cast<double>(kInt64Value)));
EXPECT_TRUE(value->Equals(expected_value.get()));
- // Pop a uint64.
+ // Pop a uint64_t.
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(
@@ -118,7 +122,7 @@ TEST(ValuesUtilTest, PopVariant) {
MessageWriter writer(response.get());
const bool kBoolValue = true;
writer.AppendVariantOfBool(kBoolValue);
- const int32 kInt32Value = -45;
+ const int32_t kInt32Value = -45;
writer.AppendVariantOfInt32(kInt32Value);
const double kDoubleValue = 4.9;
writer.AppendVariantOfDouble(kDoubleValue);
@@ -133,7 +137,7 @@ TEST(ValuesUtilTest, PopVariant) {
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::FundamentalValue(kBoolValue));
EXPECT_TRUE(value->Equals(expected_value.get()));
- // Pop an int32.
+ // Pop an int32_t.
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::FundamentalValue(kInt32Value));
@@ -156,39 +160,39 @@ TEST(ValuesUtilTest, PopExtremelyLargeIntegers) {
scoped_ptr<Response> response(Response::CreateEmpty());
// Append large integers.
MessageWriter writer(response.get());
- const int64 kInt64Value = -123456789012345689LL;
+ const int64_t kInt64Value = -123456789012345689LL;
writer.AppendInt64(kInt64Value);
- const uint64 kUint64Value = 9876543210987654321ULL;
+ const uint64_t kUint64Value = 9876543210987654321ULL;
writer.AppendUint64(kUint64Value);
MessageReader reader(response.get());
scoped_ptr<base::Value> value;
scoped_ptr<base::Value> expected_value;
double double_value = 0;
- // Pop an int64.
+ // Pop an int64_t.
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(
new base::FundamentalValue(static_cast<double>(kInt64Value)));
EXPECT_TRUE(value->Equals(expected_value.get()));
ASSERT_TRUE(value->GetAsDouble(&double_value));
- EXPECT_NE(kInt64Value, static_cast<int64>(double_value));
- // Pop a uint64.
+ EXPECT_NE(kInt64Value, static_cast<int64_t>(double_value));
+ // Pop a uint64_t.
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(
new base::FundamentalValue(static_cast<double>(kUint64Value)));
EXPECT_TRUE(value->Equals(expected_value.get()));
ASSERT_TRUE(value->GetAsDouble(&double_value));
- EXPECT_NE(kUint64Value, static_cast<uint64>(double_value));
+ EXPECT_NE(kUint64Value, static_cast<uint64_t>(double_value));
}
TEST(ValuesUtilTest, PopIntArray) {
scoped_ptr<Response> response(Response::CreateEmpty());
- // Append an int32 array.
+ // Append an int32_t array.
MessageWriter writer(response.get());
MessageWriter sub_writer(NULL);
- std::vector<int32> data;
+ std::vector<int32_t> data;
data.push_back(0);
data.push_back(1);
data.push_back(2);
@@ -202,7 +206,7 @@ TEST(ValuesUtilTest, PopIntArray) {
for (size_t i = 0; i != data.size(); ++i)
list_value->Append(new base::FundamentalValue(data[i]));
- // Pop an int32 array.
+ // Pop an int32_t array.
MessageReader reader(response.get());
scoped_ptr<base::Value> value(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
@@ -240,7 +244,7 @@ TEST(ValuesUtilTest, PopStruct) {
writer.OpenStruct(&sub_writer);
const bool kBoolValue = true;
sub_writer.AppendBool(kBoolValue);
- const int32 kInt32Value = -123;
+ const int32_t kInt32Value = -123;
sub_writer.AppendInt32(kInt32Value);
const double kDoubleValue = 1.23;
sub_writer.AppendDouble(kDoubleValue);
@@ -278,7 +282,7 @@ TEST(ValuesUtilTest, PopStringToVariantDictionary) {
sub_writer.OpenDictEntry(&entry_writer);
const std::string kKey2 = "two";
entry_writer.AppendString(kKey2);
- const int32 kInt32Value = -45;
+ const int32_t kInt32Value = -45;
entry_writer.AppendVariantOfInt32(kInt32Value);
sub_writer.CloseContainer(&entry_writer);
sub_writer.OpenDictEntry(&entry_writer);
@@ -325,7 +329,7 @@ TEST(ValuesUtilTest, PopDictionaryWithDottedStringKey) {
sub_writer.OpenDictEntry(&entry_writer);
const std::string kKey2 = ".example"; // String starting with a dot.
entry_writer.AppendString(kKey2);
- const int32 kInt32Value = -45;
+ const int32_t kInt32Value = -45;
entry_writer.AppendVariantOfInt32(kInt32Value);
sub_writer.CloseContainer(&entry_writer);
sub_writer.OpenDictEntry(&entry_writer);
@@ -354,8 +358,8 @@ TEST(ValuesUtilTest, PopDictionaryWithDottedStringKey) {
TEST(ValuesUtilTest, PopDoubleToIntDictionary) {
// Create test data.
- const int32 kValues[] = {0, 1, 1, 2, 3, 5, 8, 13, 21};
- const std::vector<int32> values(kValues, kValues + arraysize(kValues));
+ const int32_t kValues[] = {0, 1, 1, 2, 3, 5, 8, 13, 21};
+ const std::vector<int32_t> values(kValues, kValues + arraysize(kValues));
std::vector<double> keys(values.size());
for (size_t i = 0; i != values.size(); ++i)
keys[i] = std::sqrt(values[i]);
@@ -515,7 +519,7 @@ TEST(ValuesUtilTest, AppendDictionary) {
const std::string kKey6 = "six";
const bool kBoolValue = true;
- const int32 kInt32Value = -45;
+ const int32_t kInt32Value = -45;
const double kDoubleValue = 4.9;
const std::string kStringValue = "fifty";
@@ -562,7 +566,7 @@ TEST(ValuesUtilTest, AppendDictionaryAsVariant) {
const std::string kKey6 = "six";
const bool kBoolValue = true;
- const int32 kInt32Value = -45;
+ const int32_t kInt32Value = -45;
const double kDoubleValue = 4.9;
const std::string kStringValue = "fifty";
@@ -605,7 +609,7 @@ TEST(ValuesUtilTest, AppendList) {
const std::string kKey2 = "two";
const bool kBoolValue = true;
- const int32 kInt32Value = -45;
+ const int32_t kInt32Value = -45;
const double kDoubleValue = 4.9;
const std::string kStringValue = "fifty";
@@ -648,7 +652,7 @@ TEST(ValuesUtilTest, AppendListAsVariant) {
const std::string kKey2 = "two";
const bool kBoolValue = true;
- const int32 kInt32Value = -45;
+ const int32_t kInt32Value = -45;
const double kDoubleValue = 4.9;
const std::string kStringValue = "fifty";