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

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

Issue 10701012: JSON Schema Compiler: Added event compilation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reworked Create functions and lots of tests. Created 8 years, 5 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 EXPECT_TRUE(params.get()); 187 EXPECT_TRUE(params.get());
188 ASSERT_EQ(2u, params->refs.size()); 188 ASSERT_EQ(2u, params->refs.size());
189 EXPECT_EQ(1, params->refs[0]->val); 189 EXPECT_EQ(1, params->refs[0]->val);
190 EXPECT_EQ(2, params->refs[1]->val); 190 EXPECT_EQ(2, params->refs[1]->val);
191 } 191 }
192 192
193 TEST(JsonSchemaCompilerArrayTest, ReturnIntegerArrayResultCreate) { 193 TEST(JsonSchemaCompilerArrayTest, ReturnIntegerArrayResultCreate) {
194 std::vector<int> integers; 194 std::vector<int> integers;
195 integers.push_back(1); 195 integers.push_back(1);
196 integers.push_back(2); 196 integers.push_back(2);
197 scoped_ptr<Value> result(ReturnIntegerArray::Result::Create(integers)); 197 scoped_ptr<Value> results(ReturnIntegerArray::Result::Create(integers));
198 ListValue* list = NULL; 198
199 EXPECT_TRUE(result->GetAsList(&list)); 199 ListValue expected;
200 int temp; 200 ListValue* expected_argument = new ListValue();
201 ASSERT_EQ(2u, list->GetSize()); 201 expected_argument->Append(Value::CreateIntegerValue(1));
202 EXPECT_TRUE(list->GetInteger(0, &temp)); 202 expected_argument->Append(Value::CreateIntegerValue(2));
203 EXPECT_EQ(1, temp); 203 expected.Append(expected_argument);
204 EXPECT_TRUE(list->GetInteger(1, &temp)); 204 EXPECT_TRUE(results->Equals(&expected));
205 EXPECT_EQ(2, temp);
206 } 205 }
207 206
208 TEST(JsonSchemaCompilerArrayTest, ReturnRefArrayResultCreate) { 207 TEST(JsonSchemaCompilerArrayTest, ReturnRefArrayResultCreate) {
209 std::vector<linked_ptr<Item> > items; 208 std::vector<linked_ptr<Item> > items;
210 items.push_back(linked_ptr<Item>(new Item())); 209 items.push_back(linked_ptr<Item>(new Item()));
211 items.push_back(linked_ptr<Item>(new Item())); 210 items.push_back(linked_ptr<Item>(new Item()));
212 items[0]->val = 1; 211 items[0]->val = 1;
213 items[1]->val = 2; 212 items[1]->val = 2;
214 scoped_ptr<Value> result(ReturnRefArray::Result::Create(items)); 213 scoped_ptr<Value> results(ReturnRefArray::Result::Create(items));
215 ListValue* list = NULL; 214
216 EXPECT_TRUE(result->GetAsList(&list)); 215 ListValue expected;
217 ASSERT_EQ(2u, list->GetSize()); 216 ListValue* expected_argument = new ListValue();
218 DictionaryValue* item_value = NULL; 217 DictionaryValue* first = new DictionaryValue();
219 int temp; 218 first->SetInteger("val", 1);
220 EXPECT_TRUE(list->GetDictionary(0, &item_value)); 219 expected_argument->Append(first);
221 EXPECT_TRUE(item_value->GetInteger("val", &temp)); 220 DictionaryValue* second = new DictionaryValue();
222 EXPECT_EQ(1, temp); 221 second->SetInteger("val", 2);
223 EXPECT_TRUE(list->GetDictionary(1, &item_value)); 222 expected_argument->Append(second);
224 EXPECT_TRUE(item_value->GetInteger("val", &temp)); 223 expected.Append(expected_argument);
225 EXPECT_EQ(2, temp); 224 EXPECT_TRUE(results->Equals(&expected));
not at google - send to devlin 2012/07/11 07:22:06 Thanks for doing this cleanup. Check out chrome/c
Matt Tytel 2012/07/12 03:07:56 I might have gotten carried away. Done.
226 } 225 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698