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

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

Issue 9456007: Add wider support to json_schema_compiler (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: reupload 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/choices.h" 5 #include "tools/json_schema_compiler/test/choices.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::choices; 9 using namespace test::api::choices;
10 10
(...skipping 18 matching lines...) Expand all
29 { 29 {
30 scoped_ptr<ListValue> params_value(new ListValue()); 30 scoped_ptr<ListValue> params_value(new ListValue());
31 scoped_ptr<ListValue> integers(new ListValue()); 31 scoped_ptr<ListValue> integers(new ListValue());
32 integers->Append(Value::CreateIntegerValue(6)); 32 integers->Append(Value::CreateIntegerValue(6));
33 integers->Append(Value::CreateIntegerValue(8)); 33 integers->Append(Value::CreateIntegerValue(8));
34 params_value->Append(integers.release()); 34 params_value->Append(integers.release());
35 scoped_ptr<TakesIntegers::Params> params( 35 scoped_ptr<TakesIntegers::Params> params(
36 TakesIntegers::Params::Create(*params_value)); 36 TakesIntegers::Params::Create(*params_value));
37 EXPECT_TRUE(params.get()); 37 EXPECT_TRUE(params.get());
38 EXPECT_EQ(TakesIntegers::Params::NUMS_ARRAY, params->nums_type); 38 EXPECT_EQ(TakesIntegers::Params::NUMS_ARRAY, params->nums_type);
39 EXPECT_EQ(2UL, (*params->nums_array).size()); 39 EXPECT_EQ((size_t) 2, (*params->nums_array).size());
40 EXPECT_EQ(6, (*params->nums_array)[0]); 40 EXPECT_EQ(6, (*params->nums_array)[0]);
41 EXPECT_EQ(8, (*params->nums_array)[1]); 41 EXPECT_EQ(8, (*params->nums_array)[1]);
42 } 42 }
43 } 43 }
44 44
45 TEST(JsonSchemaCompilerChoicesTest, ObjectWithChoicesParamsCreate) { 45 TEST(JsonSchemaCompilerChoicesTest, ObjectWithChoicesParamsCreate) {
46 { 46 {
47 scoped_ptr<DictionaryValue> object_param(new DictionaryValue()); 47 scoped_ptr<DictionaryValue> object_param(new DictionaryValue());
48 object_param->SetWithoutPathExpansion("strings", 48 object_param->SetWithoutPathExpansion("strings",
49 Value::CreateStringValue("asdf")); 49 Value::CreateStringValue("asdf"));
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 113
114 TEST(JsonSchemaCompilerChoicesTest, ReturnChoices) { 114 TEST(JsonSchemaCompilerChoicesTest, ReturnChoices) {
115 { 115 {
116 std::vector<int> integers; 116 std::vector<int> integers;
117 integers.push_back(1); 117 integers.push_back(1);
118 integers.push_back(2); 118 integers.push_back(2);
119 scoped_ptr<Value> array_result(ReturnChoices::Result::Create(integers)); 119 scoped_ptr<Value> array_result(ReturnChoices::Result::Create(integers));
120 ListValue* list = NULL; 120 ListValue* list = NULL;
121 EXPECT_TRUE(array_result->GetAsList(&list)); 121 EXPECT_TRUE(array_result->GetAsList(&list));
122 EXPECT_EQ(2UL, list->GetSize()); 122 EXPECT_EQ((size_t) 2, list->GetSize());
123 int temp; 123 int temp;
124 EXPECT_TRUE(list->GetInteger(0, &temp)); 124 EXPECT_TRUE(list->GetInteger(0, &temp));
125 EXPECT_EQ(1, temp); 125 EXPECT_EQ(1, temp);
126 EXPECT_TRUE(list->GetInteger(1, &temp)); 126 EXPECT_TRUE(list->GetInteger(1, &temp));
127 EXPECT_EQ(2, temp); 127 EXPECT_EQ(2, temp);
128 } 128 }
129 { 129 {
130 scoped_ptr<Value> single_result(ReturnChoices::Result::Create(5)); 130 scoped_ptr<Value> single_result(ReturnChoices::Result::Create(5));
131 int temp; 131 int temp;
132 EXPECT_TRUE(single_result->GetAsInteger(&temp)); 132 EXPECT_TRUE(single_result->GetAsInteger(&temp));
133 EXPECT_EQ(5, temp); 133 EXPECT_EQ(5, temp);
134 } 134 }
135 } 135 }
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/test/arrays_unittest.cc ('k') | tools/json_schema_compiler/test/crossref.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698