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