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

Side by Side Diff: tools/json_schema_compiler/test/arrays_unittest.cc

Issue 9491002: json_schema_compiler: any, additionalProperties, functions on types (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: add any in arrays to util.h Created 8 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/json_schema_compiler/test/arrays.h" 5 #include "tools/json_schema_compiler/test/arrays.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 using namespace test::api::arrays; 9 using namespace test::api::arrays;
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 params_value->Append(integer_array.release()); 86 params_value->Append(integer_array.release());
87 scoped_ptr<IntegerArray::Params> params( 87 scoped_ptr<IntegerArray::Params> params(
88 IntegerArray::Params::Create(*params_value)); 88 IntegerArray::Params::Create(*params_value));
89 EXPECT_TRUE(params.get()); 89 EXPECT_TRUE(params.get());
90 EXPECT_EQ((size_t) 3, params->nums.size()); 90 EXPECT_EQ((size_t) 3, params->nums.size());
91 EXPECT_EQ(2, params->nums[0]); 91 EXPECT_EQ(2, params->nums[0]);
92 EXPECT_EQ(4, params->nums[1]); 92 EXPECT_EQ(4, params->nums[1]);
93 EXPECT_EQ(8, params->nums[2]); 93 EXPECT_EQ(8, params->nums[2]);
94 } 94 }
95 95
96 TEST(JsonSchemaCompilerArrayTest, AnyArrayParamsCreate) {
97 scoped_ptr<ListValue> params_value(new ListValue());
98 scoped_ptr<ListValue> any_array(new ListValue());
99 any_array->Append(Value::CreateIntegerValue(1));
100 any_array->Append(Value::CreateStringValue("test"));
101 any_array->Append(CreateItemValue(2));
102 params_value->Append(any_array.release());
103 scoped_ptr<AnyArray::Params> params(
104 AnyArray::Params::Create(*params_value));
105 EXPECT_TRUE(params.get());
106 EXPECT_EQ((size_t) 3, params->anys.size());
107 int int_temp = 0;
108 EXPECT_TRUE(params->anys[0]->value().GetAsInteger(&int_temp));
109 EXPECT_EQ(1, int_temp);
110 }
111
96 TEST(JsonSchemaCompilerArrayTest, RefArrayParamsCreate) { 112 TEST(JsonSchemaCompilerArrayTest, RefArrayParamsCreate) {
97 scoped_ptr<ListValue> params_value(new ListValue()); 113 scoped_ptr<ListValue> params_value(new ListValue());
98 scoped_ptr<ListValue> item_array(new ListValue()); 114 scoped_ptr<ListValue> item_array(new ListValue());
99 item_array->Append(CreateItemValue(1)); 115 item_array->Append(CreateItemValue(1));
100 item_array->Append(CreateItemValue(2)); 116 item_array->Append(CreateItemValue(2));
101 params_value->Append(item_array.release()); 117 params_value->Append(item_array.release());
102 scoped_ptr<RefArray::Params> params( 118 scoped_ptr<RefArray::Params> params(
103 RefArray::Params::Create(*params_value)); 119 RefArray::Params::Create(*params_value));
104 EXPECT_TRUE(params.get()); 120 EXPECT_TRUE(params.get());
105 EXPECT_EQ((size_t) 2, params->refs.size()); 121 EXPECT_EQ((size_t) 2, params->refs.size());
(...skipping 28 matching lines...) Expand all
134 EXPECT_EQ((size_t) 2, list->GetSize()); 150 EXPECT_EQ((size_t) 2, list->GetSize());
135 DictionaryValue* item_value = NULL; 151 DictionaryValue* item_value = NULL;
136 int temp; 152 int temp;
137 EXPECT_TRUE(list->GetDictionary(0, &item_value)); 153 EXPECT_TRUE(list->GetDictionary(0, &item_value));
138 EXPECT_TRUE(item_value->GetInteger("val", &temp)); 154 EXPECT_TRUE(item_value->GetInteger("val", &temp));
139 EXPECT_EQ(1, temp); 155 EXPECT_EQ(1, temp);
140 EXPECT_TRUE(list->GetDictionary(1, &item_value)); 156 EXPECT_TRUE(list->GetDictionary(1, &item_value));
141 EXPECT_TRUE(item_value->GetInteger("val", &temp)); 157 EXPECT_TRUE(item_value->GetInteger("val", &temp));
142 EXPECT_EQ(2, temp); 158 EXPECT_EQ(2, temp);
143 } 159 }
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/test/arrays.json ('k') | tools/json_schema_compiler/test/functionsOnTypes.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698