diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-29 00:45:32 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-29 00:45:32 +0000 |
commit | 14fd11947f98ad50efa67c96cc0ce7bfd06e92ba (patch) | |
tree | 1031cf0f099d73745b8113a5ce5ee18fa3268c7f | |
parent | 27a3384a28534629327753c228b5aac773696131 (diff) | |
download | chromium_src-14fd11947f98ad50efa67c96cc0ce7bfd06e92ba.zip chromium_src-14fd11947f98ad50efa67c96cc0ce7bfd06e92ba.tar.gz chromium_src-14fd11947f98ad50efa67c96cc0ce7bfd06e92ba.tar.bz2 |
Add a unittest for the JSONValueSerializer::set_allow_trailing_comma() method. Fixes the return type in the header.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/common/json_value_serializer.h | 2 | ||||
-rw-r--r-- | chrome/common/json_value_serializer_unittest.cc | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/chrome/common/json_value_serializer.h b/chrome/common/json_value_serializer.h index ff18104..c3e20bc 100644 --- a/chrome/common/json_value_serializer.h +++ b/chrome/common/json_value_serializer.h @@ -72,7 +72,7 @@ class JSONStringValueSerializer : public ValueSerializer { void set_pretty_print(bool new_value) { pretty_print_ = new_value; } bool pretty_print() { return pretty_print_; } - bool set_allow_trailing_comma(bool new_value) { + void set_allow_trailing_comma(bool new_value) { allow_trailing_comma_ = new_value; } diff --git a/chrome/common/json_value_serializer_unittest.cc b/chrome/common/json_value_serializer_unittest.cc index a4e9d89..1c2b433 100644 --- a/chrome/common/json_value_serializer_unittest.cc +++ b/chrome/common/json_value_serializer_unittest.cc @@ -187,6 +187,23 @@ TEST(JSONValueSerializerTest, HexStrings) { delete deserial_root; } +TEST(JSONValueSerializerTest, AllowTrailingComma) { + Value* root = NULL; + Value* root_expected = NULL; + std::string test_with_commas("{\"key\": [true,],}"); + std::string test_no_commas("{\"key\": [true]}"); + + JSONStringValueSerializer serializer(test_with_commas); + serializer.set_allow_trailing_comma(true); + JSONStringValueSerializer serializer_expected(test_no_commas); + ASSERT_TRUE(serializer.Deserialize(&root)); + ASSERT_TRUE(serializer_expected.Deserialize(&root_expected)); + ASSERT_TRUE(root->Equals(root_expected)); + + delete root; + delete root_expected; +} + namespace { void ValidateJsonList(const std::string& json) { |