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

Unified Diff: base/json/json_writer_unittest.cc

Issue 8505033: Allow JSONWriter and JSONValueSerializer to omit binary values when instructed to do so. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix chrome\browser\policy\configuration_policy_handler_chromeos.cc Created 9 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_writer.cc ('k') | chrome/browser/browser_about_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json/json_writer_unittest.cc
diff --git a/base/json/json_writer_unittest.cc b/base/json/json_writer_unittest.cc
index 6d7714b5aad7fd4f964a2b5fa27839fbe18db51f..aed4b73c77c71c5fdda03702a4b46f39fcddf56d 100644
--- a/base/json/json_writer_unittest.cc
+++ b/base/json/json_writer_unittest.cc
@@ -93,6 +93,32 @@ TEST(JSONWriterTest, Writing) {
period_dict3.SetWithoutPathExpansion("a.b", Value::CreateIntegerValue(1));
JSONWriter::Write(&period_dict3, false, &output_js);
ASSERT_EQ("{\"a\":{\"b\":2},\"a.b\":1}", output_js);
+
+ // Test ignoring binary values.
+ root = BinaryValue::CreateWithCopiedBuffer("asdf", 4);
+ JSONWriter::WriteWithOptions(root, false,
+ JSONWriter::OPTIONS_OMIT_BINARY_VALUES,
+ &output_js);
+ ASSERT_TRUE(output_js.empty());
+ delete root;
+
+ ListValue binary_list;
+ binary_list.Append(Value::CreateIntegerValue(5));
+ binary_list.Append(BinaryValue::CreateWithCopiedBuffer("asdf", 4));
+ binary_list.Append(Value::CreateIntegerValue(2));
+ JSONWriter::WriteWithOptions(&binary_list, false,
+ JSONWriter::OPTIONS_OMIT_BINARY_VALUES,
+ &output_js);
+ ASSERT_EQ("[5,2]", output_js);
+
+ DictionaryValue binary_dict;
+ binary_dict.Set("a", Value::CreateIntegerValue(5));
+ binary_dict.Set("b", BinaryValue::CreateWithCopiedBuffer("asdf", 4));
+ binary_dict.Set("c", Value::CreateIntegerValue(2));
+ JSONWriter::WriteWithOptions(&binary_dict, false,
+ JSONWriter::OPTIONS_OMIT_BINARY_VALUES,
+ &output_js);
+ ASSERT_EQ("{\"a\":5,\"c\":2}", output_js);
}
} // namespace base
« no previous file with comments | « base/json/json_writer.cc ('k') | chrome/browser/browser_about_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698