| Index: chrome/common/json_schema_validator_unittest_base.cc
|
| diff --git a/chrome/common/json_schema_validator_unittest_base.cc b/chrome/common/json_schema_validator_unittest_base.cc
|
| index 3e1ee7391fd24a2eebe7170e2c3a5da46506e8cb..b3cc89dd59a63fa41e9c19324e739a9c146ad060 100644
|
| --- a/chrome/common/json_schema_validator_unittest_base.cc
|
| +++ b/chrome/common/json_schema_validator_unittest_base.cc
|
| @@ -16,8 +16,11 @@
|
| #include "base/stringprintf.h"
|
| #include "base/values.h"
|
| #include "chrome/common/chrome_paths.h"
|
| +#include "chrome/common/json_schema_constants.h"
|
| #include "chrome/common/json_schema_validator.h"
|
|
|
| +namespace schema = json_schema_constants;
|
| +
|
| namespace {
|
|
|
| #define TEST_SOURCE base::StringPrintf("%s:%i", __FILE__, __LINE__)
|
| @@ -94,7 +97,9 @@ void JSONSchemaValidatorTestBase::TestComplex() {
|
| instance->Append(new DictionaryValue());
|
| ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "1",
|
| JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "number", "object"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kNumber,
|
| + schema::kObject));
|
| instance->Remove(instance->GetSize() - 1, NULL);
|
|
|
| DictionaryValue* item = NULL;
|
| @@ -113,8 +118,8 @@ void JSONSchemaValidatorTestBase::TestStringPattern() {
|
| return;
|
|
|
| scoped_ptr<DictionaryValue> schema(new DictionaryValue());
|
| - schema->SetString("type", "string");
|
| - schema->SetString("pattern", "foo+");
|
| + schema->SetString(schema::kType, schema::kString);
|
| + schema->SetString(schema::kPattern, "foo+");
|
|
|
| ExpectValid(TEST_SOURCE,
|
| scoped_ptr<Value>(Value::CreateStringValue("foo")).get(),
|
| @@ -182,9 +187,9 @@ void JSONSchemaValidatorTestBase::TestExtends() {
|
|
|
| void JSONSchemaValidatorTestBase::TestObject() {
|
| scoped_ptr<DictionaryValue> schema(new DictionaryValue());
|
| - schema->SetString("type", "object");
|
| - schema->SetString("properties.foo.type", "string");
|
| - schema->SetString("properties.bar.type", "integer");
|
| + schema->SetString(schema::kType, schema::kObject);
|
| + schema->SetString("properties.foo.type", schema::kString);
|
| + schema->SetString("properties.bar.type", schema::kInteger);
|
|
|
| scoped_ptr<DictionaryValue> instance(new DictionaryValue());
|
| instance->SetString("foo", "foo");
|
| @@ -204,11 +209,13 @@ void JSONSchemaValidatorTestBase::TestObject() {
|
| instance->SetString("bar", "42");
|
| ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "bar",
|
| JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "integer", "string"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kInteger,
|
| + schema::kString));
|
|
|
| DictionaryValue* additional_properties = new DictionaryValue();
|
| - additional_properties->SetString("type", "any");
|
| - schema->Set("additionalProperties", additional_properties);
|
| + additional_properties->SetString(schema::kType, schema::kAny);
|
| + schema->Set(schema::kAdditionalProperties, additional_properties);
|
|
|
| instance->SetInteger("bar", 42);
|
| instance->SetBoolean("extra", true);
|
| @@ -217,21 +224,23 @@ void JSONSchemaValidatorTestBase::TestObject() {
|
| instance->SetString("extra", "foo");
|
| ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
|
|
|
| - additional_properties->SetString("type", "boolean");
|
| + additional_properties->SetString(schema::kType, schema::kBoolean);
|
| instance->SetBoolean("extra", true);
|
| ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
|
|
|
| instance->SetString("extra", "foo");
|
| ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL,
|
| "extra", JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "boolean", "string"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kBoolean,
|
| + schema::kString));
|
|
|
| DictionaryValue* properties = NULL;
|
| DictionaryValue* bar_property = NULL;
|
| - ASSERT_TRUE(schema->GetDictionary("properties", &properties));
|
| + ASSERT_TRUE(schema->GetDictionary(schema::kProperties, &properties));
|
| ASSERT_TRUE(properties->GetDictionary("bar", &bar_property));
|
|
|
| - bar_property->SetBoolean("optional", true);
|
| + bar_property->SetBoolean(schema::kOptional, true);
|
| instance->Remove("extra", NULL);
|
| ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
|
| instance->Remove("bar", NULL);
|
| @@ -239,11 +248,15 @@ void JSONSchemaValidatorTestBase::TestObject() {
|
| instance->Set("bar", Value::CreateNullValue());
|
| ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL,
|
| "bar", JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "integer", "null"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kInteger,
|
| + schema::kNull));
|
| instance->SetString("bar", "42");
|
| ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL,
|
| "bar", JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "integer", "string"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kInteger,
|
| + schema::kString));
|
| }
|
|
|
| void JSONSchemaValidatorTestBase::TestTypeReference() {
|
| @@ -251,16 +264,16 @@ void JSONSchemaValidatorTestBase::TestTypeReference() {
|
| ASSERT_TRUE(types.get());
|
|
|
| scoped_ptr<DictionaryValue> schema(new DictionaryValue());
|
| - schema->SetString("type", "object");
|
| - schema->SetString("properties.foo.type", "string");
|
| + schema->SetString(schema::kType, schema::kObject);
|
| + schema->SetString("properties.foo.type", schema::kString);
|
| schema->SetString("properties.bar.$ref", "Max10Int");
|
| schema->SetString("properties.baz.$ref", "MinLengthString");
|
|
|
| scoped_ptr<DictionaryValue> schema_inline(new DictionaryValue());
|
| - schema_inline->SetString("type", "object");
|
| - schema_inline->SetString("properties.foo.type", "string");
|
| + schema_inline->SetString(schema::kType, schema::kObject);
|
| + schema_inline->SetString("properties.foo.type", schema::kString);
|
| schema_inline->SetString("properties.bar.id", "NegativeInt");
|
| - schema_inline->SetString("properties.bar.type", "integer");
|
| + schema_inline->SetString("properties.bar.type", schema::kInteger);
|
| schema_inline->SetInteger("properties.bar.maximum", 0);
|
| schema_inline->SetString("properties.baz.$ref", "NegativeInt");
|
|
|
| @@ -329,29 +342,33 @@ void JSONSchemaValidatorTestBase::TestArrayTuple() {
|
| instance->Append(Value::CreateIntegerValue(42));
|
| ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "0",
|
| JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "string", "integer"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kString,
|
| + schema::kInteger));
|
|
|
| DictionaryValue* additional_properties = new DictionaryValue();
|
| - additional_properties->SetString("type", "any");
|
| - schema->Set("additionalProperties", additional_properties);
|
| + additional_properties->SetString(schema::kType, schema::kAny);
|
| + schema->Set(schema::kAdditionalProperties, additional_properties);
|
| instance->Set(0, Value::CreateStringValue("42"));
|
| instance->Append(Value::CreateStringValue("anything"));
|
| ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
|
| instance->Set(2, new ListValue());
|
| ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
|
|
|
| - additional_properties->SetString("type", "boolean");
|
| + additional_properties->SetString(schema::kType, schema::kBoolean);
|
| ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "2",
|
| JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "boolean", "array"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kBoolean,
|
| + schema::kArray));
|
| instance->Set(2, Value::CreateBooleanValue(false));
|
| ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
|
|
|
| ListValue* items_schema = NULL;
|
| DictionaryValue* item0_schema = NULL;
|
| - ASSERT_TRUE(schema->GetList("items", &items_schema));
|
| + ASSERT_TRUE(schema->GetList(schema::kItems, &items_schema));
|
| ASSERT_TRUE(items_schema->GetDictionary(0, &item0_schema));
|
| - item0_schema->SetBoolean("optional", true);
|
| + item0_schema->SetBoolean(schema::kOptional, true);
|
| instance->Remove(2, NULL);
|
| ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
|
| // TODO(aa): I think this is inconsistent with the handling of NULL+optional
|
| @@ -361,15 +378,17 @@ void JSONSchemaValidatorTestBase::TestArrayTuple() {
|
| instance->Set(0, Value::CreateIntegerValue(42));
|
| ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "0",
|
| JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "string", "integer"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kString,
|
| + schema::kInteger));
|
| }
|
|
|
| void JSONSchemaValidatorTestBase::TestArrayNonTuple() {
|
| scoped_ptr<DictionaryValue> schema(new DictionaryValue());
|
| - schema->SetString("type", "array");
|
| - schema->SetString("items.type", "string");
|
| - schema->SetInteger("minItems", 2);
|
| - schema->SetInteger("maxItems", 3);
|
| + schema->SetString(schema::kType, schema::kArray);
|
| + schema->SetString("items.type", schema::kString);
|
| + schema->SetInteger(schema::kMinItems, 2);
|
| + schema->SetInteger(schema::kMaxItems, 3);
|
|
|
| scoped_ptr<ListValue> instance(new ListValue());
|
| instance->Append(Value::CreateStringValue("x"));
|
| @@ -394,14 +413,16 @@ void JSONSchemaValidatorTestBase::TestArrayNonTuple() {
|
| instance->Append(Value::CreateIntegerValue(42));
|
| ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "1",
|
| JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "string", "integer"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kString,
|
| + schema::kInteger));
|
| }
|
|
|
| void JSONSchemaValidatorTestBase::TestString() {
|
| scoped_ptr<DictionaryValue> schema(new DictionaryValue());
|
| - schema->SetString("type", "string");
|
| - schema->SetInteger("minLength", 1);
|
| - schema->SetInteger("maxLength", 10);
|
| + schema->SetString(schema::kType, schema::kString);
|
| + schema->SetInteger(schema::kMinLength, 1);
|
| + schema->SetInteger(schema::kMaxLength, 10);
|
|
|
| ExpectValid(TEST_SOURCE,
|
| scoped_ptr<Value>(Value::CreateStringValue("x")).get(),
|
| @@ -426,9 +447,9 @@ void JSONSchemaValidatorTestBase::TestString() {
|
|
|
| void JSONSchemaValidatorTestBase::TestNumber() {
|
| scoped_ptr<DictionaryValue> schema(new DictionaryValue());
|
| - schema->SetString("type", "number");
|
| - schema->SetInteger("minimum", 1);
|
| - schema->SetInteger("maximum", 100);
|
| + schema->SetString(schema::kType, schema::kNumber);
|
| + schema->SetInteger(schema::kMinimum, 1);
|
| + schema->SetInteger(schema::kMaximum, 100);
|
| schema->SetInteger("maxDecimal", 2);
|
|
|
| ExpectValid(TEST_SOURCE,
|
| @@ -459,66 +480,76 @@ void JSONSchemaValidatorTestBase::TestNumber() {
|
| }
|
|
|
| void JSONSchemaValidatorTestBase::TestTypeClassifier() {
|
| - EXPECT_EQ("boolean", JSONSchemaValidator::GetJSONSchemaType(
|
| - scoped_ptr<Value>(Value::CreateBooleanValue(true)).get()));
|
| - EXPECT_EQ("boolean", JSONSchemaValidator::GetJSONSchemaType(
|
| - scoped_ptr<Value>(Value::CreateBooleanValue(false)).get()));
|
| + EXPECT_EQ(std::string(schema::kBoolean),
|
| + JSONSchemaValidator::GetJSONSchemaType(
|
| + scoped_ptr<Value>(Value::CreateBooleanValue(true)).get()));
|
| + EXPECT_EQ(std::string(schema::kBoolean),
|
| + JSONSchemaValidator::GetJSONSchemaType(
|
| + scoped_ptr<Value>(Value::CreateBooleanValue(false)).get()));
|
|
|
| // It doesn't matter whether the C++ type is 'integer' or 'real'. If the
|
| // number is integral and within the representable range of integers in
|
| // double, it's classified as 'integer'.
|
| - EXPECT_EQ("integer", JSONSchemaValidator::GetJSONSchemaType(
|
| - scoped_ptr<Value>(Value::CreateIntegerValue(42)).get()));
|
| - EXPECT_EQ("integer", JSONSchemaValidator::GetJSONSchemaType(
|
| - scoped_ptr<Value>(Value::CreateIntegerValue(0)).get()));
|
| - EXPECT_EQ("integer", JSONSchemaValidator::GetJSONSchemaType(
|
| - scoped_ptr<Value>(Value::CreateDoubleValue(42)).get()));
|
| - EXPECT_EQ("integer", JSONSchemaValidator::GetJSONSchemaType(
|
| - scoped_ptr<Value>(
|
| - Value::CreateDoubleValue(pow(2.0, DBL_MANT_DIG))).get()));
|
| - EXPECT_EQ("integer", JSONSchemaValidator::GetJSONSchemaType(
|
| - scoped_ptr<Value>(
|
| - Value::CreateDoubleValue(pow(-2.0, DBL_MANT_DIG))).get()));
|
| + EXPECT_EQ(std::string(schema::kInteger),
|
| + JSONSchemaValidator::GetJSONSchemaType(
|
| + scoped_ptr<Value>(Value::CreateIntegerValue(42)).get()));
|
| + EXPECT_EQ(std::string(schema::kInteger),
|
| + JSONSchemaValidator::GetJSONSchemaType(
|
| + scoped_ptr<Value>(Value::CreateIntegerValue(0)).get()));
|
| + EXPECT_EQ(std::string(schema::kInteger),
|
| + JSONSchemaValidator::GetJSONSchemaType(
|
| + scoped_ptr<Value>(Value::CreateDoubleValue(42)).get()));
|
| + EXPECT_EQ(std::string(schema::kInteger),
|
| + JSONSchemaValidator::GetJSONSchemaType(scoped_ptr<Value>(
|
| + Value::CreateDoubleValue(pow(2.0, DBL_MANT_DIG))).get()));
|
| + EXPECT_EQ(std::string(schema::kInteger),
|
| + JSONSchemaValidator::GetJSONSchemaType(scoped_ptr<Value>(
|
| + Value::CreateDoubleValue(pow(-2.0, DBL_MANT_DIG))).get()));
|
|
|
| // "number" is only used for non-integral numbers, or numbers beyond what
|
| // double can accurately represent.
|
| - EXPECT_EQ("number", JSONSchemaValidator::GetJSONSchemaType(
|
| - scoped_ptr<Value>(Value::CreateDoubleValue(88.8)).get()));
|
| - EXPECT_EQ("number", JSONSchemaValidator::GetJSONSchemaType(
|
| - scoped_ptr<Value>(Value::CreateDoubleValue(
|
| - pow(2.0, DBL_MANT_DIG) * 2)).get()));
|
| - EXPECT_EQ("number", JSONSchemaValidator::GetJSONSchemaType(
|
| - scoped_ptr<Value>(Value::CreateDoubleValue(
|
| - pow(-2.0, DBL_MANT_DIG) * 2)).get()));
|
| -
|
| - EXPECT_EQ("string", JSONSchemaValidator::GetJSONSchemaType(
|
| - scoped_ptr<Value>(Value::CreateStringValue("foo")).get()));
|
| - EXPECT_EQ("array", JSONSchemaValidator::GetJSONSchemaType(
|
| - scoped_ptr<Value>(new ListValue()).get()));
|
| - EXPECT_EQ("object", JSONSchemaValidator::GetJSONSchemaType(
|
| - scoped_ptr<Value>(new DictionaryValue()).get()));
|
| - EXPECT_EQ("null", JSONSchemaValidator::GetJSONSchemaType(
|
| - scoped_ptr<Value>(Value::CreateNullValue()).get()));
|
| + EXPECT_EQ(std::string(schema::kNumber),
|
| + JSONSchemaValidator::GetJSONSchemaType(
|
| + scoped_ptr<Value>(Value::CreateDoubleValue(88.8)).get()));
|
| + EXPECT_EQ(std::string(schema::kNumber),
|
| + JSONSchemaValidator::GetJSONSchemaType(scoped_ptr<Value>(
|
| + Value::CreateDoubleValue(pow(2.0, DBL_MANT_DIG) * 2)).get()));
|
| + EXPECT_EQ(std::string(schema::kNumber),
|
| + JSONSchemaValidator::GetJSONSchemaType(scoped_ptr<Value>(
|
| + Value::CreateDoubleValue(pow(-2.0, DBL_MANT_DIG) * 2)).get()));
|
| +
|
| + EXPECT_EQ(std::string(schema::kString),
|
| + JSONSchemaValidator::GetJSONSchemaType(
|
| + scoped_ptr<Value>(Value::CreateStringValue("foo")).get()));
|
| + EXPECT_EQ(std::string(schema::kArray),
|
| + JSONSchemaValidator::GetJSONSchemaType(
|
| + scoped_ptr<Value>(new ListValue()).get()));
|
| + EXPECT_EQ(std::string(schema::kObject),
|
| + JSONSchemaValidator::GetJSONSchemaType(
|
| + scoped_ptr<Value>(new DictionaryValue()).get()));
|
| + EXPECT_EQ(std::string(schema::kNull),
|
| + JSONSchemaValidator::GetJSONSchemaType(
|
| + scoped_ptr<Value>(Value::CreateNullValue()).get()));
|
| }
|
|
|
| void JSONSchemaValidatorTestBase::TestTypes() {
|
| scoped_ptr<DictionaryValue> schema(new DictionaryValue());
|
|
|
| // valid
|
| - schema->SetString("type", "object");
|
| + schema->SetString(schema::kType, schema::kObject);
|
| ExpectValid(TEST_SOURCE, scoped_ptr<Value>(new DictionaryValue()).get(),
|
| schema.get(), NULL);
|
|
|
| - schema->SetString("type", "array");
|
| + schema->SetString(schema::kType, schema::kArray);
|
| ExpectValid(TEST_SOURCE, scoped_ptr<Value>(new ListValue()).get(),
|
| schema.get(), NULL);
|
|
|
| - schema->SetString("type", "string");
|
| + schema->SetString(schema::kType, schema::kString);
|
| ExpectValid(TEST_SOURCE,
|
| scoped_ptr<Value>(Value::CreateStringValue("foobar")).get(),
|
| schema.get(), NULL);
|
|
|
| - schema->SetString("type", "number");
|
| + schema->SetString(schema::kType, schema::kNumber);
|
| ExpectValid(TEST_SOURCE,
|
| scoped_ptr<Value>(Value::CreateDoubleValue(88.8)).get(),
|
| schema.get(), NULL);
|
| @@ -532,7 +563,7 @@ void JSONSchemaValidatorTestBase::TestTypes() {
|
| scoped_ptr<Value>(Value::CreateIntegerValue(0)).get(),
|
| schema.get(), NULL);
|
|
|
| - schema->SetString("type", "integer");
|
| + schema->SetString(schema::kType, schema::kInteger);
|
| ExpectValid(TEST_SOURCE,
|
| scoped_ptr<Value>(Value::CreateIntegerValue(42)).get(),
|
| schema.get(), NULL);
|
| @@ -551,7 +582,7 @@ void JSONSchemaValidatorTestBase::TestTypes() {
|
| Value::CreateDoubleValue(pow(-2.0, DBL_MANT_DIG))).get(),
|
| schema.get(), NULL);
|
|
|
| - schema->SetString("type", "boolean");
|
| + schema->SetString(schema::kType, schema::kBoolean);
|
| ExpectValid(TEST_SOURCE,
|
| scoped_ptr<Value>(Value::CreateBooleanValue(false)).get(),
|
| schema.get(), NULL);
|
| @@ -559,70 +590,88 @@ void JSONSchemaValidatorTestBase::TestTypes() {
|
| scoped_ptr<Value>(Value::CreateBooleanValue(true)).get(),
|
| schema.get(), NULL);
|
|
|
| - schema->SetString("type", "null");
|
| + schema->SetString(schema::kType, schema::kNull);
|
| ExpectValid(TEST_SOURCE,
|
| scoped_ptr<Value>(Value::CreateNullValue()).get(),
|
| schema.get(), NULL);
|
|
|
| // not valid
|
| - schema->SetString("type", "object");
|
| + schema->SetString(schema::kType, schema::kObject);
|
| ExpectNotValid(TEST_SOURCE, scoped_ptr<Value>(new ListValue()).get(),
|
| schema.get(), NULL, "",
|
| JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "object", "array"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kObject,
|
| + schema::kArray));
|
|
|
| - schema->SetString("type", "object");
|
| + schema->SetString(schema::kType, schema::kObject);
|
| ExpectNotValid(TEST_SOURCE, scoped_ptr<Value>(Value::CreateNullValue()).get(),
|
| schema.get(), NULL, "",
|
| JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "object", "null"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kObject,
|
| + schema::kNull));
|
|
|
| - schema->SetString("type", "array");
|
| + schema->SetString(schema::kType, schema::kArray);
|
| ExpectNotValid(TEST_SOURCE,
|
| scoped_ptr<Value>(Value::CreateIntegerValue(42)).get(),
|
| schema.get(), NULL, "",
|
| JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "array", "integer"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kArray,
|
| + schema::kInteger));
|
|
|
| - schema->SetString("type", "string");
|
| + schema->SetString(schema::kType, schema::kString);
|
| ExpectNotValid(TEST_SOURCE,
|
| scoped_ptr<Value>(Value::CreateIntegerValue(42)).get(),
|
| schema.get(), NULL, "",
|
| JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "string", "integer"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kString,
|
| + schema::kInteger));
|
|
|
| - schema->SetString("type", "number");
|
| + schema->SetString(schema::kType, schema::kNumber);
|
| ExpectNotValid(TEST_SOURCE,
|
| scoped_ptr<Value>(Value::CreateStringValue("42")).get(),
|
| schema.get(), NULL, "",
|
| JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "number", "string"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kNumber,
|
| + schema::kString));
|
|
|
| - schema->SetString("type", "integer");
|
| + schema->SetString(schema::kType, schema::kInteger);
|
| ExpectNotValid(TEST_SOURCE,
|
| scoped_ptr<Value>(Value::CreateDoubleValue(88.8)).get(),
|
| schema.get(), NULL, "",
|
| JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "integer", "number"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kInteger,
|
| + schema::kNumber));
|
|
|
| - schema->SetString("type", "integer");
|
| + schema->SetString(schema::kType, schema::kInteger);
|
| ExpectNotValid(TEST_SOURCE,
|
| scoped_ptr<Value>(Value::CreateDoubleValue(88.8)).get(),
|
| schema.get(), NULL, "",
|
| JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "integer", "number"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kInteger,
|
| + schema::kNumber));
|
|
|
| - schema->SetString("type", "boolean");
|
| + schema->SetString(schema::kType, schema::kBoolean);
|
| ExpectNotValid(TEST_SOURCE,
|
| scoped_ptr<Value>(Value::CreateIntegerValue(1)).get(),
|
| schema.get(), NULL, "",
|
| JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "boolean", "integer"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kBoolean,
|
| + schema::kInteger));
|
|
|
| - schema->SetString("type", "null");
|
| + schema->SetString(schema::kType, schema::kNull);
|
| ExpectNotValid(TEST_SOURCE,
|
| scoped_ptr<Value>(Value::CreateBooleanValue(false)).get(),
|
| schema.get(), NULL, "",
|
| JSONSchemaValidator::FormatErrorMessage(
|
| - JSONSchemaValidator::kInvalidType, "null", "boolean"));
|
| + JSONSchemaValidator::kInvalidType,
|
| + schema::kNull,
|
| + schema::kBoolean));
|
| }
|
|
|