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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/json/json_writer.cc ('k') | chrome/test/webdriver/commands/response.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/json/json_writer.h" 5 #include "base/json/json_writer.h"
6 #include "base/values.h" 6 #include "base/values.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace base { 9 namespace base {
10 10
11 TEST(JSONWriterTest, Writing) { 11 TEST(JSONWriterTest, Writing) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 ASSERT_EQ("[5,2]", output_js); 112 ASSERT_EQ("[5,2]", output_js);
113 113
114 DictionaryValue binary_dict; 114 DictionaryValue binary_dict;
115 binary_dict.Set("a", Value::CreateIntegerValue(5)); 115 binary_dict.Set("a", Value::CreateIntegerValue(5));
116 binary_dict.Set("b", BinaryValue::CreateWithCopiedBuffer("asdf", 4)); 116 binary_dict.Set("b", BinaryValue::CreateWithCopiedBuffer("asdf", 4));
117 binary_dict.Set("c", Value::CreateIntegerValue(2)); 117 binary_dict.Set("c", Value::CreateIntegerValue(2));
118 JSONWriter::WriteWithOptions(&binary_dict, false, 118 JSONWriter::WriteWithOptions(&binary_dict, false,
119 JSONWriter::OPTIONS_OMIT_BINARY_VALUES, 119 JSONWriter::OPTIONS_OMIT_BINARY_VALUES,
120 &output_js); 120 &output_js);
121 ASSERT_EQ("{\"a\":5,\"c\":2}", output_js); 121 ASSERT_EQ("{\"a\":5,\"c\":2}", output_js);
122
123 // Test allowing a double with no fractional part to be written as an integer.
124 FundamentalValue double_value(1e10);
125 JSONWriter::WriteWithOptions(
126 &double_value, false,
127 JSONWriter::OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION,
128 &output_js);
129 ASSERT_EQ("10000000000", output_js);
122 } 130 }
123 131
124 } // namespace base 132 } // namespace base
OLDNEW
« no previous file with comments | « base/json/json_writer.cc ('k') | chrome/test/webdriver/commands/response.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698