Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 | 32 |
| 33 bool bool_value = false; | 33 bool bool_value = false; |
| 34 ASSERT_TRUE(root_dict->GetBoolean("bool", &bool_value)); | 34 ASSERT_TRUE(root_dict->GetBoolean("bool", &bool_value)); |
| 35 ASSERT_TRUE(bool_value); | 35 ASSERT_TRUE(bool_value); |
| 36 | 36 |
| 37 int int_value = 0; | 37 int int_value = 0; |
| 38 ASSERT_TRUE(root_dict->GetInteger("int", &int_value)); | 38 ASSERT_TRUE(root_dict->GetInteger("int", &int_value)); |
| 39 ASSERT_EQ(42, int_value); | 39 ASSERT_EQ(42, int_value); |
| 40 | 40 |
| 41 double real_value = 0.0; | 41 double real_value = 0.0; |
| 42 ASSERT_TRUE(root_dict->GetReal("real", &real_value)); | 42 ASSERT_TRUE(root_dict->GetDouble("real", &real_value)); |
|
arv (Not doing code reviews)
2011/01/31 22:54:13
Renamed string locally
tony
2011/01/31 23:00:13
OK.
| |
| 43 ASSERT_DOUBLE_EQ(3.14, real_value); | 43 ASSERT_DOUBLE_EQ(3.14, real_value); |
| 44 | 44 |
| 45 // We shouldn't be able to write using this serializer, since it was | 45 // We shouldn't be able to write using this serializer, since it was |
| 46 // initialized with a const string. | 46 // initialized with a const string. |
| 47 ASSERT_FALSE(serializer.Serialize(*root_dict)); | 47 ASSERT_FALSE(serializer.Serialize(*root_dict)); |
| 48 | 48 |
| 49 std::string test_serialization = ""; | 49 std::string test_serialization = ""; |
| 50 JSONStringValueSerializer mutable_serializer(&test_serialization); | 50 JSONStringValueSerializer mutable_serializer(&test_serialization); |
| 51 ASSERT_TRUE(mutable_serializer.Serialize(*root_dict)); | 51 ASSERT_TRUE(mutable_serializer.Serialize(*root_dict)); |
| 52 ASSERT_EQ(original_serialization, test_serialization); | 52 ASSERT_EQ(original_serialization, test_serialization); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 FilePath source_file_path; | 341 FilePath source_file_path; |
| 342 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &source_file_path)); | 342 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &source_file_path)); |
| 343 source_file_path = source_file_path.Append( | 343 source_file_path = source_file_path.Append( |
| 344 FILE_PATH_LITERAL("serializer_test_nowhitespace.js")); | 344 FILE_PATH_LITERAL("serializer_test_nowhitespace.js")); |
| 345 ASSERT_TRUE(file_util::PathExists(source_file_path)); | 345 ASSERT_TRUE(file_util::PathExists(source_file_path)); |
| 346 JSONFileValueSerializer serializer(source_file_path); | 346 JSONFileValueSerializer serializer(source_file_path); |
| 347 scoped_ptr<Value> root; | 347 scoped_ptr<Value> root; |
| 348 root.reset(serializer.Deserialize(NULL, NULL)); | 348 root.reset(serializer.Deserialize(NULL, NULL)); |
| 349 ASSERT_TRUE(root.get()); | 349 ASSERT_TRUE(root.get()); |
| 350 } | 350 } |
| OLD | NEW |