summaryrefslogtreecommitdiffstats
path: root/base/json_writer_unittest.cc
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 21:17:24 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 21:17:24 +0000
commitb81637c3d9f2cf895b81d5b673b88668b6bc1322 (patch)
tree795f338852b7d40508e837ece010d64b4ad14d9f /base/json_writer_unittest.cc
parenteb0ef6ce145aab92fdf7f99f4ebe14ef7b03736c (diff)
downloadchromium_src-b81637c3d9f2cf895b81d5b673b88668b6bc1322.zip
chromium_src-b81637c3d9f2cf895b81d5b673b88668b6bc1322.tar.gz
chromium_src-b81637c3d9f2cf895b81d5b673b88668b6bc1322.tar.bz2
Use platform-appropriate newlines in JSON output.
BUG=15462 TEST=base_unittests, unit_tests, check newlines in bookmarks file Review URL: http://codereview.chromium.org/147220 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19418 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/json_writer_unittest.cc')
-rw-r--r--base/json_writer_unittest.cc21
1 files changed, 15 insertions, 6 deletions
diff --git a/base/json_writer_unittest.cc b/base/json_writer_unittest.cc
index 9f24fe1..2792982 100644
--- a/base/json_writer_unittest.cc
+++ b/base/json_writer_unittest.cc
@@ -43,7 +43,7 @@ TEST(JSONWriterTest, Writing) {
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 @@ TEST(JSONWriterTest, Writing) {
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
}