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

Side by Side Diff: base/json/json_value_serializer_unittest.cc

Issue 1131113004: Convert JsonWriter::Write to taking a const ref for the in-param (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 5 years, 7 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
« no previous file with comments | « base/json/json_string_value_serializer.cc ('k') | base/json/json_writer.h » ('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) 2012 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 <string> 5 #include <string>
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/json/json_file_value_serializer.h" 9 #include "base/json/json_file_value_serializer.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 "\xC3\xA8\xC3\xA9\xC3\xAA\xC3\xAB\xC3\xAC\xC3\xAD\xC3\xAE\xC3\xAF\xC3\xB0" 295 "\xC3\xA8\xC3\xA9\xC3\xAA\xC3\xAB\xC3\xAC\xC3\xAD\xC3\xAE\xC3\xAF\xC3\xB0"
296 "\xC3\xB1\xC3\xB2\xC3\xB3\xC3\xB4\xC3\xB5\xC3\xB6\xC3\xB7\xC3\xB8\xC3\xB9" 296 "\xC3\xB1\xC3\xB2\xC3\xB3\xC3\xB4\xC3\xB5\xC3\xB6\xC3\xB7\xC3\xB8\xC3\xB9"
297 "\xC3\xBA\xC3\xBB\xC3\xBC\xC3\xBD\xC3\xBE\xC3\xBF"; 297 "\xC3\xBA\xC3\xBB\xC3\xBC\xC3\xBD\xC3\xBE\xC3\xBF";
298 298
299 std::string expected_output = "{\"all_chars\":\"" + all_chars_expected + 299 std::string expected_output = "{\"all_chars\":\"" + all_chars_expected +
300 "\"}"; 300 "\"}";
301 // Test JSONWriter interface 301 // Test JSONWriter interface
302 std::string output_js; 302 std::string output_js;
303 DictionaryValue valueRoot; 303 DictionaryValue valueRoot;
304 valueRoot.SetString("all_chars", all_chars); 304 valueRoot.SetString("all_chars", all_chars);
305 JSONWriter::Write(&valueRoot, &output_js); 305 JSONWriter::Write(valueRoot, &output_js);
306 ASSERT_EQ(expected_output, output_js); 306 ASSERT_EQ(expected_output, output_js);
307 307
308 // Test JSONValueSerializer interface (uses JSONWriter). 308 // Test JSONValueSerializer interface (uses JSONWriter).
309 JSONStringValueSerializer serializer(&output_js); 309 JSONStringValueSerializer serializer(&output_js);
310 ASSERT_TRUE(serializer.Serialize(valueRoot)); 310 ASSERT_TRUE(serializer.Serialize(valueRoot));
311 ASSERT_EQ(expected_output, output_js); 311 ASSERT_EQ(expected_output, output_js);
312 } 312 }
313 313
314 TEST(JSONValueSerializerTest, UnicodeStrings) { 314 TEST(JSONValueSerializerTest, UnicodeStrings) {
315 // unicode string json -> escaped ascii text 315 // unicode string json -> escaped ascii text
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 ASSERT_TRUE(PathExists(source_file_path)); 488 ASSERT_TRUE(PathExists(source_file_path));
489 JSONFileValueDeserializer deserializer(source_file_path); 489 JSONFileValueDeserializer deserializer(source_file_path);
490 scoped_ptr<Value> root; 490 scoped_ptr<Value> root;
491 root.reset(deserializer.Deserialize(NULL, NULL)); 491 root.reset(deserializer.Deserialize(NULL, NULL));
492 ASSERT_TRUE(root.get()); 492 ASSERT_TRUE(root.get());
493 } 493 }
494 494
495 } // namespace 495 } // namespace
496 496
497 } // namespace base 497 } // namespace base
OLDNEW
« no previous file with comments | « base/json/json_string_value_serializer.cc ('k') | base/json/json_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698