diff options
Diffstat (limited to 'base/json_writer_unittest.cc')
-rw-r--r-- | base/json_writer_unittest.cc | 21 |
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 } |