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

Unified Diff: base/json/json_value_serializer_unittest.cc

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 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/json_value_converter_unittest.cc ('k') | base/json/json_writer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json/json_value_serializer_unittest.cc
diff --git a/base/json/json_value_serializer_unittest.cc b/base/json/json_value_serializer_unittest.cc
index a8531f08e17c3d1bae71ca1d996d83f59ef314c7..77d015c451d374a323ae52cd95b5a1ee3eae8847 100644
--- a/base/json/json_value_serializer_unittest.cc
+++ b/base/json/json_value_serializer_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
#include <string>
#include "base/files/file_util.h"
@@ -10,7 +11,6 @@
#include "base/json/json_reader.h"
#include "base/json/json_string_value_serializer.h"
#include "base/json/json_writer.h"
-#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
@@ -76,7 +76,7 @@ void CheckJSONIsStillTheSame(const Value& value) {
}
void ValidateJsonList(const std::string& json) {
- scoped_ptr<Value> root = JSONReader::Read(json);
+ std::unique_ptr<Value> root = JSONReader::Read(json);
ASSERT_TRUE(root.get() && root->IsType(Value::TYPE_LIST));
ListValue* list = static_cast<ListValue*>(root.get());
ASSERT_EQ(1U, list->GetSize());
@@ -94,7 +94,7 @@ TEST(JSONValueDeserializerTest, ReadProperJSONFromString) {
int error_code = 0;
std::string error_message;
- scoped_ptr<Value> value =
+ std::unique_ptr<Value> value =
str_deserializer.Deserialize(&error_code, &error_message);
ASSERT_TRUE(value.get());
ASSERT_EQ(0, error_code);
@@ -113,7 +113,7 @@ TEST(JSONValueDeserializerTest, ReadProperJSONFromStringPiece) {
int error_code = 0;
std::string error_message;
- scoped_ptr<Value> value =
+ std::unique_ptr<Value> value =
str_deserializer.Deserialize(&error_code, &error_message);
ASSERT_TRUE(value.get());
ASSERT_EQ(0, error_code);
@@ -130,7 +130,7 @@ TEST(JSONValueDeserializerTest, ReadJSONWithTrailingCommasFromString) {
int error_code = 0;
std::string error_message;
- scoped_ptr<Value> value =
+ std::unique_ptr<Value> value =
str_deserializer.Deserialize(&error_code, &error_message);
ASSERT_FALSE(value.get());
ASSERT_NE(0, error_code);
@@ -158,7 +158,7 @@ TEST(JSONValueDeserializerTest, ReadProperJSONFromFile) {
int error_code = 0;
std::string error_message;
- scoped_ptr<Value> value =
+ std::unique_ptr<Value> value =
file_deserializer.Deserialize(&error_code, &error_message);
ASSERT_TRUE(value.get());
ASSERT_EQ(0, error_code);
@@ -183,7 +183,7 @@ TEST(JSONValueDeserializerTest, ReadJSONWithCommasFromFile) {
// This must fail without the proper flag.
int error_code = 0;
std::string error_message;
- scoped_ptr<Value> value =
+ std::unique_ptr<Value> value =
file_deserializer.Deserialize(&error_code, &error_message);
ASSERT_FALSE(value.get());
ASSERT_NE(0, error_code);
@@ -198,8 +198,8 @@ TEST(JSONValueDeserializerTest, ReadJSONWithCommasFromFile) {
}
TEST(JSONValueDeserializerTest, AllowTrailingComma) {
- scoped_ptr<Value> root;
- scoped_ptr<Value> root_expected;
+ std::unique_ptr<Value> root;
+ std::unique_ptr<Value> root_expected;
static const char kTestWithCommas[] = "{\"key\": [true,],}";
static const char kTestNoCommas[] = "{\"key\": [true]}";
@@ -217,7 +217,7 @@ TEST(JSONValueSerializerTest, Roundtrip) {
static const char kOriginalSerialization[] =
"{\"bool\":true,\"double\":3.14,\"int\":42,\"list\":[1,2],\"null\":null}";
JSONStringValueDeserializer deserializer(kOriginalSerialization);
- scoped_ptr<Value> root = deserializer.Deserialize(NULL, NULL);
+ std::unique_ptr<Value> root = deserializer.Deserialize(NULL, NULL);
ASSERT_TRUE(root.get());
ASSERT_TRUE(root->IsType(Value::TYPE_DICTIONARY));
@@ -327,7 +327,7 @@ TEST(JSONValueSerializerTest, UnicodeStrings) {
// escaped ascii text -> json
JSONStringValueDeserializer deserializer(kExpected);
- scoped_ptr<Value> deserial_root = deserializer.Deserialize(NULL, NULL);
+ std::unique_ptr<Value> deserial_root = deserializer.Deserialize(NULL, NULL);
ASSERT_TRUE(deserial_root.get());
DictionaryValue* dict_root =
static_cast<DictionaryValue*>(deserial_root.get());
@@ -351,7 +351,7 @@ TEST(JSONValueSerializerTest, HexStrings) {
// escaped ascii text -> json
JSONStringValueDeserializer deserializer(kExpected);
- scoped_ptr<Value> deserial_root = deserializer.Deserialize(NULL, NULL);
+ std::unique_ptr<Value> deserial_root = deserializer.Deserialize(NULL, NULL);
ASSERT_TRUE(deserial_root.get());
DictionaryValue* dict_root =
static_cast<DictionaryValue*>(deserial_root.get());
@@ -378,7 +378,7 @@ TEST(JSONValueSerializerTest, JSONReaderComments) {
ValidateJsonList("[ 1 //// ,2\r\n ]");
// It's ok to have a comment in a string.
- scoped_ptr<Value> root = JSONReader::Read("[\"// ok\\n /* foo */ \"]");
+ std::unique_ptr<Value> root = JSONReader::Read("[\"// ok\\n /* foo */ \"]");
ASSERT_TRUE(root.get() && root->IsType(Value::TYPE_LIST));
ListValue* list = static_cast<ListValue*>(root.get());
ASSERT_EQ(1U, list->GetSize());
@@ -413,7 +413,7 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) {
ASSERT_TRUE(PathExists(original_file_path));
JSONFileValueDeserializer deserializer(original_file_path);
- scoped_ptr<Value> root;
+ std::unique_ptr<Value> root;
root = deserializer.Deserialize(NULL, NULL);
ASSERT_TRUE(root.get());
@@ -461,7 +461,7 @@ TEST_F(JSONFileValueSerializerTest, RoundtripNested) {
ASSERT_TRUE(PathExists(original_file_path));
JSONFileValueDeserializer deserializer(original_file_path);
- scoped_ptr<Value> root;
+ std::unique_ptr<Value> root;
root = deserializer.Deserialize(NULL, NULL);
ASSERT_TRUE(root.get());
@@ -486,7 +486,7 @@ TEST_F(JSONFileValueSerializerTest, NoWhitespace) {
FILE_PATH_LITERAL("serializer_test_nowhitespace.json"));
ASSERT_TRUE(PathExists(source_file_path));
JSONFileValueDeserializer deserializer(source_file_path);
- scoped_ptr<Value> root;
+ std::unique_ptr<Value> root;
root = deserializer.Deserialize(NULL, NULL);
ASSERT_TRUE(root.get());
}
« no previous file with comments | « base/json/json_value_converter_unittest.cc ('k') | base/json/json_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698