Index: base/json/json_reader_unittest.cc |
diff --git a/base/json/json_reader_unittest.cc b/base/json/json_reader_unittest.cc |
index a7aeaf0f5569fb7ca776af264d2a4eb2d99f97f2..641de0fb24b68ee076ec01c5ae4dc5995f703a70 100644 |
--- a/base/json/json_reader_unittest.cc |
+++ b/base/json/json_reader_unittest.cc |
@@ -2,13 +2,14 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "testing/gtest/include/gtest/gtest.h" |
+#include "base/basictypes.h" |
#include "base/json/json_reader.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/string_piece.h" |
#include "base/utf_string_conversions.h" |
#include "base/values.h" |
#include "build/build_config.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
namespace base { |
@@ -53,6 +54,12 @@ TEST(JSONReaderTest, Reading) { |
int int_val = 0; |
ASSERT_TRUE(root->GetAsInteger(&int_val)); |
ASSERT_EQ(43, int_val); |
+ root.reset(JSONReader().JsonToValue("2147483648", false, false)); |
+ ASSERT_TRUE(root.get()); |
+ ASSERT_TRUE(root->IsType(Value::TYPE_INTEGER64)); |
+ int64 int64_val = 0; |
+ ASSERT_TRUE(root->GetAsInteger64(&int64_val)); |
+ ASSERT_EQ(2147483648, int64_val); |
// According to RFC4627, oct, hex, and leading zeros are invalid JSON. |
root.reset(JSONReader().JsonToValue("043", false, false)); |
@@ -71,21 +78,21 @@ TEST(JSONReaderTest, Reading) { |
ASSERT_TRUE(root->GetAsInteger(&int_val)); |
ASSERT_EQ(0, int_val); |
- // Numbers that overflow ints should succeed, being internally promoted to |
+ // Numbers that overflow int64s should succeed, being internally promoted to |
// storage as doubles |
- root.reset(JSONReader().JsonToValue("2147483648", false, false)); |
+ root.reset(JSONReader().JsonToValue("9223372036854775808", false, false)); |
ASSERT_TRUE(root.get()); |
double double_val; |
ASSERT_TRUE(root->IsType(Value::TYPE_DOUBLE)); |
double_val = 0.0; |
ASSERT_TRUE(root->GetAsDouble(&double_val)); |
- ASSERT_DOUBLE_EQ(2147483648.0, double_val); |
- root.reset(JSONReader().JsonToValue("-2147483649", false, false)); |
+ ASSERT_DOUBLE_EQ(9223372036854775808.0, double_val); |
+ root.reset(JSONReader().JsonToValue("-9223372036854775809", false, false)); |
ASSERT_TRUE(root.get()); |
ASSERT_TRUE(root->IsType(Value::TYPE_DOUBLE)); |
double_val = 0.0; |
ASSERT_TRUE(root->GetAsDouble(&double_val)); |
- ASSERT_DOUBLE_EQ(-2147483649.0, double_val); |
+ ASSERT_DOUBLE_EQ(-9223372036854775809.0, double_val); |
// Parse a double |
root.reset(JSONReader().JsonToValue("43.1", false, false)); |