Fix a type mismatch on Windows caused by r201738.
[chromium-blink-merge.git] / tools / json_schema_compiler / test / additional_properties_unittest.cc
blob5e08d5e266303d2d9ac66cd23effd5be606ec6cd
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/json_schema_compiler/test/additional_properties.h"
8 using namespace test::api::additional_properties;
10 TEST(JsonSchemaCompilerAdditionalPropertiesTest,
11 AdditionalPropertiesTypePopulate) {
13 scoped_ptr<ListValue> list_value(new ListValue());
14 list_value->Append(Value::CreateStringValue("asdf"));
15 list_value->Append(Value::CreateIntegerValue(4));
16 scoped_ptr<DictionaryValue> type_value(new DictionaryValue());
17 type_value->SetString("string", "value");
18 type_value->SetInteger("other", 9);
19 type_value->Set("another", list_value.release());
20 scoped_ptr<AdditionalPropertiesType> type(new AdditionalPropertiesType());
21 ASSERT_TRUE(AdditionalPropertiesType::Populate(*type_value, type.get()));
22 EXPECT_TRUE(type->additional_properties.Equals(type_value.get()));
25 scoped_ptr<DictionaryValue> type_value(new DictionaryValue());
26 type_value->SetInteger("string", 3);
27 scoped_ptr<AdditionalPropertiesType> type(new AdditionalPropertiesType());
28 EXPECT_FALSE(AdditionalPropertiesType::Populate(*type_value, type.get()));
32 TEST(JsonSchemaCompilerAdditionalPropertiesTest,
33 AdditionalPropertiesParamsCreate) {
34 scoped_ptr<DictionaryValue> param_object_value(new DictionaryValue());
35 param_object_value->SetString("str", "a");
36 param_object_value->SetInteger("num", 1);
37 scoped_ptr<ListValue> params_value(new ListValue());
38 params_value->Append(param_object_value->DeepCopy());
39 scoped_ptr<AdditionalProperties::Params> params(
40 AdditionalProperties::Params::Create(*params_value));
41 EXPECT_TRUE(params.get());
42 EXPECT_TRUE(params->param_object.additional_properties.Equals(
43 param_object_value.get()));
46 TEST(JsonSchemaCompilerAdditionalPropertiesTest,
47 ReturnAdditionalPropertiesResultCreate) {
48 ReturnAdditionalProperties::Results::ResultObject result_object;
49 result_object.integer = 5;
50 result_object.additional_properties["key"] = "value";
52 ListValue expected;
54 DictionaryValue* dict = new DictionaryValue();
55 dict->SetInteger("integer", 5);
56 dict->SetString("key", "value");
57 expected.Append(dict);
60 EXPECT_TRUE(Value::Equals(
61 ReturnAdditionalProperties::Results::Create(result_object).get(),
62 &expected));