Commit e6726e21 authored by jieluo@google.com's avatar jieluo@google.com

use decimal constants to avoid casting error with visual c /W4

"unary minus operator applied to unsigned type, result still unsigned"
parent 76b8a769
...@@ -270,9 +270,9 @@ string Int64ToString(int64 number) { ...@@ -270,9 +270,9 @@ string Int64ToString(int64 number) {
// gcc rejects the decimal form of kint64min // gcc rejects the decimal form of kint64min
if (number == kint64min) { if (number == kint64min) {
// Make sure we are in a 2's complement system. // Make sure we are in a 2's complement system.
GOOGLE_COMPILE_ASSERT(kint64min == GOOGLE_LONGLONG(-0x8000000000000000), GOOGLE_COMPILE_ASSERT(kint64min == GOOGLE_LONGLONG(~0x7fffffffffffffff),
kint64min_value_error); kint64min_value_error);
return "GOOGLE_LONGLONG(-0x8000000000000000)"; return "GOOGLE_LONGLONG(~0x7fffffffffffffff)";
} }
return "GOOGLE_LONGLONG(" + SimpleItoa(number) + ")"; return "GOOGLE_LONGLONG(" + SimpleItoa(number) + ")";
} }
......
...@@ -159,7 +159,7 @@ TEST(GeneratedMessageTest, Int32StringConversion) { ...@@ -159,7 +159,7 @@ TEST(GeneratedMessageTest, Int32StringConversion) {
TEST(GeneratedMessageTest, Int64StringConversion) { TEST(GeneratedMessageTest, Int64StringConversion) {
EXPECT_EQ("GOOGLE_LONGLONG(971)", Int64ToString(971)); EXPECT_EQ("GOOGLE_LONGLONG(971)", Int64ToString(971));
EXPECT_EQ("GOOGLE_LONGLONG(-2147483648)", Int64ToString(kint32min)); EXPECT_EQ("GOOGLE_LONGLONG(-2147483648)", Int64ToString(kint32min));
EXPECT_EQ("GOOGLE_LONGLONG(-0x8000000000000000)", Int64ToString(kint64min)); EXPECT_EQ("GOOGLE_LONGLONG(~0x7fffffffffffffff)", Int64ToString(kint64min));
EXPECT_EQ("GOOGLE_LONGLONG(9223372036854775807)", Int64ToString(kint64max)); EXPECT_EQ("GOOGLE_LONGLONG(9223372036854775807)", Int64ToString(kint64max));
} }
...@@ -196,8 +196,8 @@ TEST(GeneratedMessageTest, Trigraph) { ...@@ -196,8 +196,8 @@ TEST(GeneratedMessageTest, Trigraph) {
TEST(GeneratedMessageTest, ExtremeSmallIntegerDefault) { TEST(GeneratedMessageTest, ExtremeSmallIntegerDefault) {
const unittest::TestExtremeDefaultValues& extreme_default = const unittest::TestExtremeDefaultValues& extreme_default =
unittest::TestExtremeDefaultValues::default_instance(); unittest::TestExtremeDefaultValues::default_instance();
EXPECT_EQ(-0x80000000, kint32min); EXPECT_EQ(~0x7fffffff, kint32min);
EXPECT_EQ(GOOGLE_LONGLONG(-0x8000000000000000), kint64min); EXPECT_EQ(GOOGLE_LONGLONG(~0x7fffffffffffffff), kint64min);
EXPECT_EQ(kint32min, extreme_default.really_small_int32()); EXPECT_EQ(kint32min, extreme_default.really_small_int32());
EXPECT_EQ(kint64min, extreme_default.really_small_int64()); EXPECT_EQ(kint64min, extreme_default.really_small_int64());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment