| OLD | NEW |
| 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 Loading... |
| 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; |
| 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 Loading... |
| 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 |
| OLD | NEW |