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

Unified Diff: base/json/json_value_serializer_unittest.cc

Issue 2475583002: Adds option for JSON reader to allow invalid utf characters (Closed)
Patch Set: comment Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/json/json_string_value_serializer.cc ('k') | chrome/browser/ui/app_list/start_page_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json/json_value_serializer_unittest.cc
diff --git a/base/json/json_value_serializer_unittest.cc b/base/json/json_value_serializer_unittest.cc
index 5bf07fd386cde55f45f30a3300ec6188d7430d10..43ddc9c4574cd63b5d5a3a2fb8523a3986ef5079 100644
--- a/base/json/json_value_serializer_unittest.cc
+++ b/base/json/json_value_serializer_unittest.cc
@@ -134,9 +134,10 @@ TEST(JSONValueDeserializerTest, ReadJSONWithTrailingCommasFromString) {
ASSERT_FALSE(value);
ASSERT_NE(0, error_code);
ASSERT_FALSE(error_message.empty());
- // Now the flag is set and it must pass.
- str_deserializer.set_allow_trailing_comma(true);
- value = str_deserializer.Deserialize(&error_code, &error_message);
+ // Repeat with commas allowed.
+ JSONStringValueDeserializer str_deserializer2(kProperJSONWithCommas,
+ JSON_ALLOW_TRAILING_COMMAS);
+ value = str_deserializer2.Deserialize(&error_code, &error_message);
ASSERT_TRUE(value);
ASSERT_EQ(JSONReader::JSON_TRAILING_COMMA, error_code);
// Verify if the same JSON is still there.
@@ -187,9 +188,10 @@ TEST(JSONValueDeserializerTest, ReadJSONWithCommasFromFile) {
ASSERT_FALSE(value);
ASSERT_NE(0, error_code);
ASSERT_FALSE(error_message.empty());
- // Now the flag is set and it must pass.
- file_deserializer.set_allow_trailing_comma(true);
- value = file_deserializer.Deserialize(&error_code, &error_message);
+ // Repeat with commas allowed.
+ JSONFileValueDeserializer file_deserializer2(temp_file,
+ JSON_ALLOW_TRAILING_COMMAS);
+ value = file_deserializer2.Deserialize(&error_code, &error_message);
ASSERT_TRUE(value);
ASSERT_EQ(JSONReader::JSON_TRAILING_COMMA, error_code);
// Verify if the same JSON is still there.
@@ -200,8 +202,8 @@ TEST(JSONValueDeserializerTest, AllowTrailingComma) {
static const char kTestWithCommas[] = "{\"key\": [true,],}";
static const char kTestNoCommas[] = "{\"key\": [true]}";
- JSONStringValueDeserializer deserializer(kTestWithCommas);
- deserializer.set_allow_trailing_comma(true);
+ JSONStringValueDeserializer deserializer(kTestWithCommas,
+ JSON_ALLOW_TRAILING_COMMAS);
JSONStringValueDeserializer deserializer_expected(kTestNoCommas);
std::unique_ptr<Value> root = deserializer.Deserialize(nullptr, nullptr);
ASSERT_TRUE(root);
« no previous file with comments | « base/json/json_string_value_serializer.cc ('k') | chrome/browser/ui/app_list/start_page_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698