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

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

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-run on ToT, revert third_party changes and fix vexing parses. Created 7 years, 8 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
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/file_util.h" 7 #include "base/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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 ASSERT_EQ(42, int_value); 189 ASSERT_EQ(42, int_value);
190 190
191 double double_value = 0.0; 191 double double_value = 0.0;
192 ASSERT_TRUE(root_dict->GetDouble("double", &double_value)); 192 ASSERT_TRUE(root_dict->GetDouble("double", &double_value));
193 ASSERT_DOUBLE_EQ(3.14, double_value); 193 ASSERT_DOUBLE_EQ(3.14, double_value);
194 194
195 // We shouldn't be able to write using this serializer, since it was 195 // We shouldn't be able to write using this serializer, since it was
196 // initialized with a const string. 196 // initialized with a const string.
197 ASSERT_FALSE(serializer.Serialize(*root_dict)); 197 ASSERT_FALSE(serializer.Serialize(*root_dict));
198 198
199 std::string test_serialization = ""; 199 std::string test_serialization = std::string();
darin (slow to review) 2013/04/09 05:27:57 nit: gratuitous assignment.
200 JSONStringValueSerializer mutable_serializer(&test_serialization); 200 JSONStringValueSerializer mutable_serializer(&test_serialization);
201 ASSERT_TRUE(mutable_serializer.Serialize(*root_dict)); 201 ASSERT_TRUE(mutable_serializer.Serialize(*root_dict));
202 ASSERT_EQ(original_serialization, test_serialization); 202 ASSERT_EQ(original_serialization, test_serialization);
203 203
204 mutable_serializer.set_pretty_print(true); 204 mutable_serializer.set_pretty_print(true);
205 ASSERT_TRUE(mutable_serializer.Serialize(*root_dict)); 205 ASSERT_TRUE(mutable_serializer.Serialize(*root_dict));
206 // JSON output uses a different newline style on Windows than on other 206 // JSON output uses a different newline style on Windows than on other
207 // platforms. 207 // platforms.
208 #if defined(OS_WIN) 208 #if defined(OS_WIN)
209 #define JSON_NEWLINE "\r\n" 209 #define JSON_NEWLINE "\r\n"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 ASSERT_TRUE(file_util::PathExists(source_file_path)); 464 ASSERT_TRUE(file_util::PathExists(source_file_path));
465 JSONFileValueSerializer serializer(source_file_path); 465 JSONFileValueSerializer serializer(source_file_path);
466 scoped_ptr<Value> root; 466 scoped_ptr<Value> root;
467 root.reset(serializer.Deserialize(NULL, NULL)); 467 root.reset(serializer.Deserialize(NULL, NULL));
468 ASSERT_TRUE(root.get()); 468 ASSERT_TRUE(root.get());
469 } 469 }
470 470
471 } // namespace 471 } // namespace
472 472
473 } // namespace base 473 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698