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

Side by Side Diff: chrome/browser/safe_json_parser_browsertest.cc

Issue 1131113004: Convert JsonWriter::Write to taking a const ref for the in-param (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/json/json_reader.h" 6 #include "base/json/json_reader.h"
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/safe_json_parser.h" 10 #include "chrome/browser/safe_json_parser.h"
11 #include "chrome/test/base/in_process_browser_test.h" 11 #include "chrome/test/base/in_process_browser_test.h"
12 #include "content/public/test/test_browser_thread_bundle.h" 12 #include "content/public/test/test_browser_thread_bundle.h"
13 #include "content/public/test/test_utils.h" 13 #include "content/public/test/test_utils.h"
14 14
15 namespace { 15 namespace {
16 16
17 std::string MaybeToJson(const base::Value* value) { 17 std::string MaybeToJson(const base::Value* value) {
18 if (!value) 18 if (!value)
19 return "(null)"; 19 return "(null)";
20 20
21 std::string json; 21 std::string json;
22 if (!base::JSONWriter::Write(value, &json)) 22 if (!base::JSONWriter::Write(*value, &json))
23 return "(invalid value)"; 23 return "(invalid value)";
24 24
25 return json; 25 return json;
26 } 26 }
27 27
28 } // namespace 28 } // namespace
29 29
30 class SafeJsonParserTest : public InProcessBrowserTest { 30 class SafeJsonParserTest : public InProcessBrowserTest {
31 protected: 31 protected:
32 void TestParse(const std::string& json) { 32 void TestParse(const std::string& json) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 TestParse("\"laser\""); 95 TestParse("\"laser\"");
96 TestParse("false"); 96 TestParse("false");
97 TestParse("null"); 97 TestParse("null");
98 TestParse("3.14"); 98 TestParse("3.14");
99 TestParse("["); 99 TestParse("[");
100 TestParse("\""); 100 TestParse("\"");
101 TestParse(std::string()); 101 TestParse(std::string());
102 TestParse("☃"); 102 TestParse("☃");
103 TestParse("\"☃\""); 103 TestParse("\"☃\"");
104 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698