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 316016: Move the json-related files into a separate json directory. This hopefully al... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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') | base/string_escape.h » ('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 29830)
+++ base/json_writer_unittest.cc (working copy)
@@ -1,77 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "testing/gtest/include/gtest/gtest.h"
-#include "base/json_writer.h"
-#include "base/values.h"
-
-TEST(JSONWriterTest, Writing) {
- // Test null
- Value* root = Value::CreateNullValue();
- std::string output_js;
- JSONWriter::Write(root, false, &output_js);
- ASSERT_EQ("null", output_js);
- delete root;
-
- // Test empty dict
- root = new DictionaryValue;
- JSONWriter::Write(root, false, &output_js);
- ASSERT_EQ("{}", output_js);
- delete root;
-
- // Test empty list
- root = new ListValue;
- JSONWriter::Write(root, false, &output_js);
- ASSERT_EQ("[]", output_js);
- delete root;
-
- // Test Real values should always have a decimal or an 'e'.
- root = Value::CreateRealValue(1.0);
- JSONWriter::Write(root, false, &output_js);
- ASSERT_EQ("1.0", output_js);
- delete root;
-
- // Test Real values in the the range (-1, 1) must have leading zeros
- root = Value::CreateRealValue(0.2);
- JSONWriter::Write(root, false, &output_js);
- ASSERT_EQ("0.2", output_js);
- delete root;
-
- // Test Real values in the the range (-1, 1) must have leading zeros
- root = Value::CreateRealValue(-0.8);
- 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;
- ListValue* list = new ListValue;
- root_dict.Set(L"list", list);
- DictionaryValue* inner_dict = new DictionaryValue;
- list->Append(inner_dict);
- inner_dict->SetInteger(L"inner int", 10);
- ListValue* inner_list = new ListValue;
- 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);
- // 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') | base/string_escape.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698