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

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

Issue 2884933002: Remove raw base::DictionaryValue::SetWithoutPathExpansion (Closed)
Patch Set: Include Created 3 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 side-by-side diff with in-line comments
Download patch
Index: tools/json_schema_compiler/test/error_generation_unittest.cc
diff --git a/tools/json_schema_compiler/test/error_generation_unittest.cc b/tools/json_schema_compiler/test/error_generation_unittest.cc
index 9c22682bbf1409b6c9b832c417282602d6ff3055..06a3a9c98cbb740f1e62d6b56023e1b7798b5db0 100644
--- a/tools/json_schema_compiler/test/error_generation_unittest.cc
+++ b/tools/json_schema_compiler/test/error_generation_unittest.cc
@@ -36,7 +36,7 @@ testing::AssertionResult EqualsUtf16(const std::string& expected,
TEST(JsonSchemaCompilerErrorTest, RequiredPropertyPopulate) {
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("string", new base::Value("bling"));
+ Dictionary("string", base::MakeUnique<base::Value>("bling"));
EXPECT_TRUE(EqualsUtf16("", GetPopulateError<TestType>(*value)));
}
{
@@ -64,7 +64,7 @@ TEST(JsonSchemaCompilerErrorTest, UnexpectedTypePopulation) {
TEST(JsonSchemaCompilerErrorTest, TypeIsRequired) {
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("integers", new Value(5));
+ Dictionary("integers", base::MakeUnique<Value>(5));
EXPECT_TRUE(EqualsUtf16("", GetPopulateError<ChoiceType>(*value)));
}
{
@@ -78,13 +78,14 @@ TEST(JsonSchemaCompilerErrorTest, TypeIsRequired) {
TEST(JsonSchemaCompilerErrorTest, TooManyParameters) {
{
- std::unique_ptr<base::ListValue> params_value = List(new Value(5));
+ std::unique_ptr<base::ListValue> params_value =
+ List(base::MakeUnique<Value>(5));
base::string16 error;
EXPECT_TRUE(TestFunction::Params::Create(*params_value, &error));
}
{
std::unique_ptr<base::ListValue> params_value =
- List(new Value(5), new Value(5));
+ List(base::MakeUnique<Value>(5), base::MakeUnique<Value>(5));
base::string16 error;
EXPECT_FALSE(TestFunction::Params::Create(*params_value, &error));
EXPECT_TRUE(EqualsUtf16("expected 1 arguments, got 2", error));
@@ -95,12 +96,14 @@ TEST(JsonSchemaCompilerErrorTest, TooManyParameters) {
TEST(JsonSchemaCompilerErrorTest, ParamIsRequired) {
{
- std::unique_ptr<base::ListValue> params_value = List(new Value(5));
+ std::unique_ptr<base::ListValue> params_value =
+ List(base::MakeUnique<Value>(5));
base::string16 error;
EXPECT_TRUE(TestFunction::Params::Create(*params_value, &error));
}
{
- std::unique_ptr<base::ListValue> params_value = List(new Value());
+ std::unique_ptr<base::ListValue> params_value =
+ List(base::MakeUnique<Value>());
base::string16 error;
EXPECT_FALSE(TestFunction::Params::Create(*params_value, &error));
EXPECT_TRUE(EqualsUtf16("'num' is required", error));
@@ -112,12 +115,12 @@ TEST(JsonSchemaCompilerErrorTest, ParamIsRequired) {
TEST(JsonSchemaCompilerErrorTest, WrongPropertyValueType) {
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("string", new base::Value("yes"));
+ Dictionary("string", base::MakeUnique<base::Value>("yes"));
EXPECT_TRUE(EqualsUtf16("", GetPopulateError<TestType>(*value)));
}
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("string", new Value(1.1));
+ Dictionary("string", base::MakeUnique<Value>(1.1));
EXPECT_TRUE(EqualsUtf16("'string': expected string, got double",
GetPopulateError<TestType>(*value)));
}
@@ -127,11 +130,12 @@ TEST(JsonSchemaCompilerErrorTest, WrongParameterCreationType) {
{
base::string16 error;
std::unique_ptr<base::ListValue> params_value =
- List(new base::Value("Yeah!"));
+ List(base::MakeUnique<base::Value>("Yeah!"));
EXPECT_TRUE(TestString::Params::Create(*params_value, &error));
}
{
- std::unique_ptr<base::ListValue> params_value = List(new Value(5));
+ std::unique_ptr<base::ListValue> params_value =
+ List(base::MakeUnique<Value>(5));
base::string16 error;
EXPECT_FALSE(TestTypeInObject::Params::Create(*params_value, &error));
EXPECT_TRUE(EqualsUtf16("'paramObject': expected dictionary, got integer",
@@ -146,7 +150,7 @@ TEST(JsonSchemaCompilerErrorTest, WrongTypeValueType) {
}
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("otherType", new Value(1.1));
+ Dictionary("otherType", base::MakeUnique<Value>(1.1));
ObjectType out;
base::string16 error;
EXPECT_TRUE(ObjectType::Populate(*value, &out, &error));
@@ -158,13 +162,14 @@ TEST(JsonSchemaCompilerErrorTest, WrongTypeValueType) {
TEST(JsonSchemaCompilerErrorTest, UnableToPopulateArray) {
{
- std::unique_ptr<base::ListValue> params_value = List(new Value(5));
+ std::unique_ptr<base::ListValue> params_value =
+ List(base::MakeUnique<Value>(5));
EXPECT_TRUE(EqualsUtf16("",
GetPopulateError<ChoiceType::Integers>(*params_value)));
}
{
std::unique_ptr<base::ListValue> params_value =
- List(new Value(5), new Value(false));
+ List(base::MakeUnique<Value>(5), base::MakeUnique<Value>(false));
EXPECT_TRUE(EqualsUtf16(
"expected integer, got boolean; unable to populate array 'integers'",
GetPopulateError<ChoiceType::Integers>(*params_value)));
@@ -173,13 +178,13 @@ TEST(JsonSchemaCompilerErrorTest, UnableToPopulateArray) {
TEST(JsonSchemaCompilerErrorTest, BinaryTypeExpected) {
{
- std::unique_ptr<base::DictionaryValue> value =
- Dictionary("data", new base::Value(base::Value::Type::BINARY));
+ std::unique_ptr<base::DictionaryValue> value = Dictionary(
+ "data", base::MakeUnique<base::Value>(base::Value::Type::BINARY));
EXPECT_TRUE(EqualsUtf16("", GetPopulateError<BinaryData>(*value)));
}
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("data", new Value(1.1));
+ Dictionary("data", base::MakeUnique<Value>(1.1));
EXPECT_TRUE(EqualsUtf16("'data': expected binary, got double",
GetPopulateError<BinaryData>(*value)));
}
@@ -188,12 +193,12 @@ TEST(JsonSchemaCompilerErrorTest, BinaryTypeExpected) {
TEST(JsonSchemaCompilerErrorTest, ListExpected) {
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("TheArray", new base::ListValue());
+ Dictionary("TheArray", base::MakeUnique<base::ListValue>());
EXPECT_TRUE(EqualsUtf16("", GetPopulateError<ArrayObject>(*value)));
}
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("TheArray", new Value(5));
+ Dictionary("TheArray", base::MakeUnique<Value>(5));
EXPECT_TRUE(EqualsUtf16("'TheArray': expected list, got integer",
GetPopulateError<ArrayObject>(*value)));
}
@@ -204,12 +209,12 @@ TEST(JsonSchemaCompilerErrorTest, ListExpected) {
TEST(JsonSchemaCompilerErrorTest, BadEnumValue) {
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("enumeration", new base::Value("one"));
+ Dictionary("enumeration", base::MakeUnique<base::Value>("one"));
EXPECT_TRUE(EqualsUtf16("", GetPopulateError<HasEnumeration>(*value)));
}
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("enumeration", new base::Value("bad sauce"));
+ Dictionary("enumeration", base::MakeUnique<base::Value>("bad sauce"));
EXPECT_TRUE(EqualsUtf16("'Enumeration': expected \"one\" or \"two\" "
"or \"three\", got \"bad sauce\"",
GetPopulateError<HasEnumeration>(*value)));
@@ -221,12 +226,12 @@ TEST(JsonSchemaCompilerErrorTest, BadEnumValue) {
TEST(JsonSchemaCompilerErrorTest, WarnOnOptionalFailure) {
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("string", new base::Value("bling"));
+ Dictionary("string", base::MakeUnique<base::Value>("bling"));
EXPECT_TRUE(EqualsUtf16("", GetPopulateError<OptionalTestType>(*value)));
}
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("string", new base::Value(1));
+ Dictionary("string", base::MakeUnique<base::Value>(1));
OptionalTestType out;
base::string16 error;
@@ -239,14 +244,14 @@ TEST(JsonSchemaCompilerErrorTest, WarnOnOptionalFailure) {
TEST(JsonSchemaCompilerErrorTest, OptionalBinaryTypeFailure) {
{
- std::unique_ptr<base::DictionaryValue> value =
- Dictionary("data", new base::Value(base::Value::Type::BINARY));
+ std::unique_ptr<base::DictionaryValue> value = Dictionary(
+ "data", base::MakeUnique<base::Value>(base::Value::Type::BINARY));
EXPECT_TRUE(EqualsUtf16("", GetPopulateError<OptionalBinaryData>(*value)));
}
{
// There's a bug with silent failures if the key doesn't exist.
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("data", new base::Value(1));
+ Dictionary("data", base::MakeUnique<base::Value>(1));
OptionalBinaryData out;
base::string16 error;
@@ -260,12 +265,12 @@ TEST(JsonSchemaCompilerErrorTest, OptionalBinaryTypeFailure) {
TEST(JsonSchemaCompilerErrorTest, OptionalArrayTypeFailure) {
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("TheArray", new base::ListValue());
+ Dictionary("TheArray", base::MakeUnique<base::ListValue>());
EXPECT_TRUE(EqualsUtf16("", GetPopulateError<ArrayObject>(*value)));
}
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("TheArray", new Value(5));
+ Dictionary("TheArray", base::MakeUnique<Value>(5));
ArrayObject out;
base::string16 error;
EXPECT_TRUE(ArrayObject::Populate(*value, &out, &error));
@@ -277,13 +282,14 @@ TEST(JsonSchemaCompilerErrorTest, OptionalArrayTypeFailure) {
TEST(JsonSchemaCompilerErrorTest, OptionalUnableToPopulateArray) {
{
- std::unique_ptr<base::ListValue> params_value = List(new Value(5));
+ std::unique_ptr<base::ListValue> params_value =
+ List(base::MakeUnique<Value>(5));
EXPECT_TRUE(EqualsUtf16("",
GetPopulateError<OptionalChoiceType::Integers>(*params_value)));
}
{
std::unique_ptr<base::ListValue> params_value =
- List(new Value(5), new Value(false));
+ List(base::MakeUnique<Value>(5), base::MakeUnique<Value>(false));
OptionalChoiceType::Integers out;
base::string16 error;
EXPECT_TRUE(OptionalChoiceType::Integers::Populate(*params_value, &out,
@@ -298,7 +304,7 @@ TEST(JsonSchemaCompilerErrorTest, OptionalUnableToPopulateArray) {
TEST(JsonSchemaCompilerErrorTest, MultiplePopulationErrors) {
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("TheArray", new Value(5));
+ Dictionary("TheArray", base::MakeUnique<Value>(5));
ArrayObject out;
base::string16 error;
EXPECT_TRUE(ArrayObject::Populate(*value, &out, &error));
@@ -317,13 +323,13 @@ TEST(JsonSchemaCompilerErrorTest, MultiplePopulationErrors) {
TEST(JsonSchemaCompilerErrorTest, TooManyKeys) {
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("string", new base::Value("yes"));
+ Dictionary("string", base::MakeUnique<base::Value>("yes"));
EXPECT_TRUE(EqualsUtf16("", GetPopulateError<TestType>(*value)));
}
{
std::unique_ptr<base::DictionaryValue> value =
- Dictionary("string", new base::Value("yes"), "ohno",
- new base::Value("many values"));
+ Dictionary("string", base::MakeUnique<base::Value>("yes"), "ohno",
+ base::MakeUnique<base::Value>("many values"));
EXPECT_TRUE(EqualsUtf16("found unexpected key 'ohno'",
GetPopulateError<TestType>(*value)));
}
« no previous file with comments | « tools/json_schema_compiler/test/enums_unittest.cc ('k') | tools/json_schema_compiler/test/simple_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698