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

Unified Diff: base/json/json_writer_unittest.cc

Issue 9016024: Add option for not adding '.0' to the end of doubles that have no fractional (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 8 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 side-by-side diff with in-line comments
Download patch
Index: base/json/json_writer_unittest.cc
diff --git a/base/json/json_writer_unittest.cc b/base/json/json_writer_unittest.cc
index 5d44c020efa5b59ce405dce26e98e484d60e18fc..fea0c44b787248dd2067cab408d0bdb32cdba69e 100644
--- a/base/json/json_writer_unittest.cc
+++ b/base/json/json_writer_unittest.cc
@@ -119,6 +119,13 @@ TEST(JSONWriterTest, Writing) {
JSONWriter::OPTIONS_OMIT_BINARY_VALUES,
&output_js);
ASSERT_EQ("{\"a\":5,\"c\":2}", output_js);
+
+ // Test allowing a double with no fractional part to be written as an integer.
+ FundamentalValue double_value(1e10);
+ JSONWriter::WriteWithOptions(&double_value, false,
+ JSONWriter::OPTIONS_ALLOW_DOUBLES_AS_INTEGERS,
+ &output_js);
+ ASSERT_EQ("10000000000", output_js);
}
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698