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

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

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 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
« no previous file with comments | « base/json/BUILD.gn ('k') | base/mac/authorization_util.mm » ('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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 " \"some_String\": \"1337\",\n" 54 " \"some_String\": \"1337\",\n"
55 " \"some_int\": 42,\n" 55 " \"some_int\": 42,\n"
56 " \"the_list\": [ \"val1\", \"val2\" ]\n" 56 " \"the_list\": [ \"val1\", \"val2\" ]\n"
57 "}\n" 57 "}\n"
58 "?!ab\n"; 58 "?!ab\n";
59 59
60 const char kWinLineEnds[] = "\r\n"; 60 const char kWinLineEnds[] = "\r\n";
61 const char kLinuxLineEnds[] = "\n"; 61 const char kLinuxLineEnds[] = "\n";
62 62
63 // Verifies the generated JSON against the expected output. 63 // Verifies the generated JSON against the expected output.
64 void CheckJSONIsStillTheSame(Value& value) { 64 void CheckJSONIsStillTheSame(const Value& value) {
65 // Serialize back the output. 65 // Serialize back the output.
66 std::string serialized_json; 66 std::string serialized_json;
67 JSONStringValueSerializer str_serializer(&serialized_json); 67 JSONStringValueSerializer str_serializer(&serialized_json);
68 str_serializer.set_pretty_print(true); 68 str_serializer.set_pretty_print(true);
69 ASSERT_TRUE(str_serializer.Serialize(value)); 69 ASSERT_TRUE(str_serializer.Serialize(value));
70 // Unify line endings between platforms. 70 // Unify line endings between platforms.
71 ReplaceSubstringsAfterOffset(&serialized_json, 0, 71 ReplaceSubstringsAfterOffset(&serialized_json, 0,
72 kWinLineEnds, kLinuxLineEnds); 72 kWinLineEnds, kLinuxLineEnds);
73 // Now compare the input with the output. 73 // Now compare the input with the output.
74 ASSERT_EQ(kProperJSON, serialized_json); 74 ASSERT_EQ(kProperJSON, serialized_json);
(...skipping 413 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/BUILD.gn ('k') | base/mac/authorization_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698