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

Unified Diff: base/json_writer_unittest.cc

Issue 147220: Use platform-appropriate newlines in JSON output (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months 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_writer.cc ('k') | chrome/common/json_value_serializer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json_writer_unittest.cc
===================================================================
--- base/json_writer_unittest.cc (revision 19366)
+++ base/json_writer_unittest.cc (working copy)
@@ -43,7 +43,7 @@
JSONWriter::Write(root, false, &output_js);
ASSERT_EQ("-0.8", output_js);
delete root;
-
+
// Writer unittests like empty list/dict nesting,
// list list nesting, etc.
DictionaryValue root_dict;
@@ -56,13 +56,22 @@
list->Append(inner_list);
list->Append(Value::CreateBooleanValue(true));
+ // Test the pretty-printer.
JSONWriter::Write(&root_dict, false, &output_js);
ASSERT_EQ("{\"list\":[{\"inner int\":10},[],true]}", output_js);
JSONWriter::Write(&root_dict, true, &output_js);
- ASSERT_EQ("{\r\n"
- " \"list\": [ {\r\n"
- " \"inner int\": 10\r\n"
- " }, [ ], true ]\r\n"
- "}\r\n",
+ // The pretty-printer uses a different newline style on Windows than on
+ // other platforms.
+#if defined(OS_WIN)
+#define JSON_NEWLINE "\r\n"
+#else
+#define JSON_NEWLINE "\n"
+#endif
+ ASSERT_EQ("{" JSON_NEWLINE
+ " \"list\": [ {" JSON_NEWLINE
+ " \"inner int\": 10" JSON_NEWLINE
+ " }, [ ], true ]" JSON_NEWLINE
+ "}" JSON_NEWLINE,
output_js);
+#undef JSON_NEWLINE
}
« no previous file with comments | « base/json_writer.cc ('k') | chrome/common/json_value_serializer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698