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

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

Issue 383263005: Remove more CreateIntegerValue calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/SetBoolean/SetInteger Created 6 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 | Annotate | Revision Log
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 "base/strings/string_piece.h" 7 #include "base/strings/string_piece.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "tools/json_schema_compiler/test/test_util.h" 9 #include "tools/json_schema_compiler/test/test_util.h"
10 10
11 namespace { 11 namespace {
12 12
13 using namespace test::api::choices; 13 using namespace test::api::choices;
14 using json_schema_compiler::test_util::Dictionary; 14 using json_schema_compiler::test_util::Dictionary;
15 using json_schema_compiler::test_util::List; 15 using json_schema_compiler::test_util::List;
16 using json_schema_compiler::test_util::ReadJson; 16 using json_schema_compiler::test_util::ReadJson;
17 using json_schema_compiler::test_util::Vector; 17 using json_schema_compiler::test_util::Vector;
18 18
19 TEST(JsonSchemaCompilerChoicesTest, TakesIntegersParamsCreate) { 19 TEST(JsonSchemaCompilerChoicesTest, TakesIntegersParamsCreate) {
20 { 20 {
21 scoped_ptr<TakesIntegers::Params> params(TakesIntegers::Params::Create( 21 scoped_ptr<TakesIntegers::Params> params(TakesIntegers::Params::Create(
22 *List(base::Value::CreateBooleanValue(true)))); 22 *List(base::Value::CreateBooleanValue(true))));
23 EXPECT_FALSE(params); 23 EXPECT_FALSE(params);
24 } 24 }
25 { 25 {
26 scoped_ptr<TakesIntegers::Params> params(TakesIntegers::Params::Create( 26 scoped_ptr<TakesIntegers::Params> params(
27 *List(base::Value::CreateIntegerValue(6)))); 27 TakesIntegers::Params::Create(*List(new base::FundamentalValue(6))));
28 ASSERT_TRUE(params); 28 ASSERT_TRUE(params);
29 EXPECT_FALSE(params->nums.as_integers); 29 EXPECT_FALSE(params->nums.as_integers);
30 EXPECT_EQ(6, *params->nums.as_integer); 30 EXPECT_EQ(6, *params->nums.as_integer);
31 } 31 }
32 { 32 {
33 scoped_ptr<TakesIntegers::Params> params(TakesIntegers::Params::Create( 33 scoped_ptr<TakesIntegers::Params> params(TakesIntegers::Params::Create(
34 *List(List(base::Value::CreateIntegerValue(2), 34 *List(List(new base::FundamentalValue(2),
35 base::Value::CreateIntegerValue(6), 35 new base::FundamentalValue(6),
36 base::Value::CreateIntegerValue(8)).release()))); 36 new base::FundamentalValue(8)).release())));
37 ASSERT_TRUE(params); 37 ASSERT_TRUE(params);
38 ASSERT_TRUE(params->nums.as_integers); 38 ASSERT_TRUE(params->nums.as_integers);
39 EXPECT_EQ(Vector(2, 6, 8), *params->nums.as_integers); 39 EXPECT_EQ(Vector(2, 6, 8), *params->nums.as_integers);
40 } 40 }
41 } 41 }
42 42
43 TEST(JsonSchemaCompilerChoicesTest, ObjectWithChoicesParamsCreate) { 43 TEST(JsonSchemaCompilerChoicesTest, ObjectWithChoicesParamsCreate) {
44 { 44 {
45 scoped_ptr<ObjectWithChoices::Params> params( 45 scoped_ptr<ObjectWithChoices::Params> params(
46 ObjectWithChoices::Params::Create(*List( 46 ObjectWithChoices::Params::Create(*List(
(...skipping 17 matching lines...) Expand all
64 } 64 }
65 } 65 }
66 66
67 // TODO(kalman): Clean up the rest of these tests to use the 67 // TODO(kalman): Clean up the rest of these tests to use the
68 // Vector/List/Dictionary helpers. 68 // Vector/List/Dictionary helpers.
69 69
70 TEST(JsonSchemaCompilerChoicesTest, ObjectWithChoicesParamsCreateFail) { 70 TEST(JsonSchemaCompilerChoicesTest, ObjectWithChoicesParamsCreateFail) {
71 { 71 {
72 scoped_ptr<base::DictionaryValue> object_param(new base::DictionaryValue()); 72 scoped_ptr<base::DictionaryValue> object_param(new base::DictionaryValue());
73 object_param->SetWithoutPathExpansion("strings", 73 object_param->SetWithoutPathExpansion("strings",
74 base::Value::CreateIntegerValue(5)); 74 new base::FundamentalValue(5));
75 scoped_ptr<base::ListValue> params_value(new base::ListValue()); 75 scoped_ptr<base::ListValue> params_value(new base::ListValue());
76 params_value->Append(object_param.release()); 76 params_value->Append(object_param.release());
77 scoped_ptr<ObjectWithChoices::Params> params( 77 scoped_ptr<ObjectWithChoices::Params> params(
78 ObjectWithChoices::Params::Create(*params_value)); 78 ObjectWithChoices::Params::Create(*params_value));
79 EXPECT_FALSE(params.get()); 79 EXPECT_FALSE(params.get());
80 } 80 }
81 { 81 {
82 scoped_ptr<base::DictionaryValue> object_param(new base::DictionaryValue()); 82 scoped_ptr<base::DictionaryValue> object_param(new base::DictionaryValue());
83 object_param->SetWithoutPathExpansion("strings", 83 object_param->SetWithoutPathExpansion("strings",
84 base::Value::CreateStringValue("asdf")); 84 base::Value::CreateStringValue("asdf"));
85 object_param->SetWithoutPathExpansion("integers", 85 object_param->SetWithoutPathExpansion("integers",
86 base::Value::CreateStringValue("asdf")); 86 base::Value::CreateStringValue("asdf"));
87 scoped_ptr<base::ListValue> params_value(new base::ListValue()); 87 scoped_ptr<base::ListValue> params_value(new base::ListValue());
88 params_value->Append(object_param.release()); 88 params_value->Append(object_param.release());
89 scoped_ptr<ObjectWithChoices::Params> params( 89 scoped_ptr<ObjectWithChoices::Params> params(
90 ObjectWithChoices::Params::Create(*params_value)); 90 ObjectWithChoices::Params::Create(*params_value));
91 EXPECT_FALSE(params.get()); 91 EXPECT_FALSE(params.get());
92 } 92 }
93 { 93 {
94 scoped_ptr<base::DictionaryValue> object_param(new base::DictionaryValue()); 94 scoped_ptr<base::DictionaryValue> object_param(new base::DictionaryValue());
95 object_param->SetWithoutPathExpansion("integers", 95 object_param->SetWithoutPathExpansion("integers",
96 base::Value::CreateIntegerValue(6)); 96 new base::FundamentalValue(6));
97 scoped_ptr<base::ListValue> params_value(new base::ListValue()); 97 scoped_ptr<base::ListValue> params_value(new base::ListValue());
98 params_value->Append(object_param.release()); 98 params_value->Append(object_param.release());
99 scoped_ptr<ObjectWithChoices::Params> params( 99 scoped_ptr<ObjectWithChoices::Params> params(
100 ObjectWithChoices::Params::Create(*params_value)); 100 ObjectWithChoices::Params::Create(*params_value));
101 EXPECT_FALSE(params.get()); 101 EXPECT_FALSE(params.get());
102 } 102 }
103 } 103 }
104 104
105 TEST(JsonSchemaCompilerChoicesTest, PopulateChoiceType) { 105 TEST(JsonSchemaCompilerChoicesTest, PopulateChoiceType) {
106 std::vector<std::string> strings = Vector(std::string("list"), 106 std::vector<std::string> strings = Vector(std::string("list"),
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 obj->as_choice2->as_choice_types.get(); 283 obj->as_choice2->as_choice_types.get();
284 // Bleh too much effort to test everything. 284 // Bleh too much effort to test everything.
285 ASSERT_EQ(2u, choice_types->size()); 285 ASSERT_EQ(2u, choice_types->size());
286 } 286 }
287 287
288 EXPECT_TRUE(base::Value::Equals(value.get(), obj->ToValue().get())); 288 EXPECT_TRUE(base::Value::Equals(value.get(), obj->ToValue().get()));
289 } 289 }
290 } 290 }
291 291
292 } // namespace 292 } // namespace
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/test/callbacks_unittest.cc ('k') | tools/json_schema_compiler/test/crossref_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698