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

Unified Diff: tools/json_schema_compiler/test/arrays_unittest.cc

Issue 1869503004: Convert //tools to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, change iwyu fixes for converted directories to include <memory> 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
Index: tools/json_schema_compiler/test/arrays_unittest.cc
diff --git a/tools/json_schema_compiler/test/arrays_unittest.cc b/tools/json_schema_compiler/test/arrays_unittest.cc
index 2c3a461514976fa9e38d2b1ea1ffcb0784035d9c..0c99be93d47e8960dc2d0d75e1a07db69f44952e 100644
--- a/tools/json_schema_compiler/test/arrays_unittest.cc
+++ b/tools/json_schema_compiler/test/arrays_unittest.cc
@@ -6,6 +6,8 @@
#include <stddef.h>
+#include <memory>
+
#include "base/macros.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "tools/json_schema_compiler/test/enums.h"
@@ -15,8 +17,8 @@ using namespace test::api::arrays;
namespace {
// TODO(calamity): Change to AppendString etc once kalman's patch goes through
-static scoped_ptr<base::DictionaryValue> CreateBasicArrayTypeDictionary() {
- base::DictionaryValue* value = new base::DictionaryValue();
+static std::unique_ptr<base::DictionaryValue> CreateBasicArrayTypeDictionary() {
+ std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
base::ListValue* strings_value = new base::ListValue();
strings_value->Append(new base::StringValue("a"));
strings_value->Append(new base::StringValue("b"));
@@ -35,7 +37,7 @@ static scoped_ptr<base::DictionaryValue> CreateBasicArrayTypeDictionary() {
value->Set("booleans", booleans_value);
value->Set("strings", strings_value);
value->Set("integers", integers_value);
- return scoped_ptr<base::DictionaryValue>(value);
+ return value;
}
static base::Value* CreateItemValue(int val) {
@@ -48,8 +50,9 @@ static base::Value* CreateItemValue(int val) {
TEST(JsonSchemaCompilerArrayTest, BasicArrayType) {
{
- scoped_ptr<base::DictionaryValue> value = CreateBasicArrayTypeDictionary();
- scoped_ptr<BasicArrayType> basic_array_type(new BasicArrayType());
+ std::unique_ptr<base::DictionaryValue> value =
+ CreateBasicArrayTypeDictionary();
+ std::unique_ptr<BasicArrayType> basic_array_type(new BasicArrayType());
ASSERT_TRUE(BasicArrayType::Populate(*value, basic_array_type.get()));
EXPECT_TRUE(value->Equals(basic_array_type->ToValue().get()));
}
@@ -76,7 +79,7 @@ TEST(JsonSchemaCompilerArrayTest, EnumArrayReference) {
enum_array_reference.types);
// Test ToValue.
- scoped_ptr<base::Value> as_value(enum_array_reference.ToValue());
+ std::unique_ptr<base::Value> as_value(enum_array_reference.ToValue());
EXPECT_TRUE(value.Equals(as_value.get())) << value << " != " << *as_value;
}
@@ -117,7 +120,7 @@ TEST(JsonSchemaCompilerArrayTest, EnumArrayMixed) {
enum_array_mixed.external_enums);
// Test ToValue.
- scoped_ptr<base::Value> as_value(enum_array_mixed.ToValue());
+ std::unique_ptr<base::Value> as_value(enum_array_mixed.ToValue());
EXPECT_TRUE(value.Equals(as_value.get())) << value << " != " << *as_value;
}
@@ -128,7 +131,7 @@ TEST(JsonSchemaCompilerArrayTest, OptionalEnumArrayType) {
enums.push_back(ENUMERATION_TWO);
enums.push_back(ENUMERATION_THREE);
- scoped_ptr<base::ListValue> types(new base::ListValue());
+ std::unique_ptr<base::ListValue> types(new base::ListValue());
for (size_t i = 0; i < enums.size(); ++i)
types->Append(new base::StringValue(ToString(enums[i])));
@@ -141,7 +144,7 @@ TEST(JsonSchemaCompilerArrayTest, OptionalEnumArrayType) {
}
{
base::DictionaryValue value;
- scoped_ptr<base::ListValue> enum_array(new base::ListValue());
+ std::unique_ptr<base::ListValue> enum_array(new base::ListValue());
enum_array->Append(new base::StringValue("invalid"));
value.Set("types", enum_array.release());
@@ -153,13 +156,13 @@ TEST(JsonSchemaCompilerArrayTest, OptionalEnumArrayType) {
TEST(JsonSchemaCompilerArrayTest, RefArrayType) {
{
- scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
- scoped_ptr<base::ListValue> ref_array(new base::ListValue());
+ std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
+ std::unique_ptr<base::ListValue> ref_array(new base::ListValue());
ref_array->Append(CreateItemValue(1));
ref_array->Append(CreateItemValue(2));
ref_array->Append(CreateItemValue(3));
value->Set("refs", ref_array.release());
- scoped_ptr<RefArrayType> ref_array_type(new RefArrayType());
+ std::unique_ptr<RefArrayType> ref_array_type(new RefArrayType());
EXPECT_TRUE(RefArrayType::Populate(*value, ref_array_type.get()));
ASSERT_EQ(3u, ref_array_type->refs.size());
EXPECT_EQ(1, ref_array_type->refs[0].val);
@@ -167,24 +170,24 @@ TEST(JsonSchemaCompilerArrayTest, RefArrayType) {
EXPECT_EQ(3, ref_array_type->refs[2].val);
}
{
- scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
- scoped_ptr<base::ListValue> not_ref_array(new base::ListValue());
+ std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
+ std::unique_ptr<base::ListValue> not_ref_array(new base::ListValue());
not_ref_array->Append(CreateItemValue(1));
not_ref_array->Append(new base::FundamentalValue(3));
value->Set("refs", not_ref_array.release());
- scoped_ptr<RefArrayType> ref_array_type(new RefArrayType());
+ std::unique_ptr<RefArrayType> ref_array_type(new RefArrayType());
EXPECT_FALSE(RefArrayType::Populate(*value, ref_array_type.get()));
}
}
TEST(JsonSchemaCompilerArrayTest, IntegerArrayParamsCreate) {
- scoped_ptr<base::ListValue> params_value(new base::ListValue());
- scoped_ptr<base::ListValue> integer_array(new base::ListValue());
+ std::unique_ptr<base::ListValue> params_value(new base::ListValue());
+ std::unique_ptr<base::ListValue> integer_array(new base::ListValue());
integer_array->Append(new base::FundamentalValue(2));
integer_array->Append(new base::FundamentalValue(4));
integer_array->Append(new base::FundamentalValue(8));
params_value->Append(integer_array.release());
- scoped_ptr<IntegerArray::Params> params(
+ std::unique_ptr<IntegerArray::Params> params(
IntegerArray::Params::Create(*params_value));
EXPECT_TRUE(params.get());
ASSERT_EQ(3u, params->nums.size());
@@ -194,13 +197,13 @@ TEST(JsonSchemaCompilerArrayTest, IntegerArrayParamsCreate) {
}
TEST(JsonSchemaCompilerArrayTest, AnyArrayParamsCreate) {
- scoped_ptr<base::ListValue> params_value(new base::ListValue());
- scoped_ptr<base::ListValue> any_array(new base::ListValue());
+ std::unique_ptr<base::ListValue> params_value(new base::ListValue());
+ std::unique_ptr<base::ListValue> any_array(new base::ListValue());
any_array->Append(new base::FundamentalValue(1));
any_array->Append(new base::StringValue("test"));
any_array->Append(CreateItemValue(2));
params_value->Append(any_array.release());
- scoped_ptr<AnyArray::Params> params(
+ std::unique_ptr<AnyArray::Params> params(
AnyArray::Params::Create(*params_value));
EXPECT_TRUE(params.get());
ASSERT_EQ(3u, params->anys.size());
@@ -210,12 +213,12 @@ TEST(JsonSchemaCompilerArrayTest, AnyArrayParamsCreate) {
}
TEST(JsonSchemaCompilerArrayTest, ObjectArrayParamsCreate) {
- scoped_ptr<base::ListValue> params_value(new base::ListValue());
- scoped_ptr<base::ListValue> item_array(new base::ListValue());
+ std::unique_ptr<base::ListValue> params_value(new base::ListValue());
+ std::unique_ptr<base::ListValue> item_array(new base::ListValue());
item_array->Append(CreateItemValue(1));
item_array->Append(CreateItemValue(2));
params_value->Append(item_array.release());
- scoped_ptr<ObjectArray::Params> params(
+ std::unique_ptr<ObjectArray::Params> params(
ObjectArray::Params::Create(*params_value));
EXPECT_TRUE(params.get());
ASSERT_EQ(2u, params->objects.size());
@@ -224,12 +227,12 @@ TEST(JsonSchemaCompilerArrayTest, ObjectArrayParamsCreate) {
}
TEST(JsonSchemaCompilerArrayTest, RefArrayParamsCreate) {
- scoped_ptr<base::ListValue> params_value(new base::ListValue());
- scoped_ptr<base::ListValue> item_array(new base::ListValue());
+ std::unique_ptr<base::ListValue> params_value(new base::ListValue());
+ std::unique_ptr<base::ListValue> item_array(new base::ListValue());
item_array->Append(CreateItemValue(1));
item_array->Append(CreateItemValue(2));
params_value->Append(item_array.release());
- scoped_ptr<RefArray::Params> params(
+ std::unique_ptr<RefArray::Params> params(
RefArray::Params::Create(*params_value));
EXPECT_TRUE(params.get());
ASSERT_EQ(2u, params->refs.size());
@@ -241,7 +244,7 @@ TEST(JsonSchemaCompilerArrayTest, ReturnIntegerArrayResultCreate) {
std::vector<int> integers;
integers.push_back(1);
integers.push_back(2);
- scoped_ptr<base::ListValue> results =
+ std::unique_ptr<base::ListValue> results =
ReturnIntegerArray::Results::Create(integers);
base::ListValue expected;
@@ -258,7 +261,7 @@ TEST(JsonSchemaCompilerArrayTest, ReturnRefArrayResultCreate) {
items.push_back(Item());
items[0].val = 1;
items[1].val = 2;
- scoped_ptr<base::ListValue> results =
+ std::unique_ptr<base::ListValue> results =
ReturnRefArray::Results::Create(items);
base::ListValue expected;
« no previous file with comments | « tools/json_schema_compiler/test/any_unittest.cc ('k') | tools/json_schema_compiler/test/callbacks_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698