OLD | NEW |
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 "testing/gtest/include/gtest/gtest.h" |
5 #include "tools/json_schema_compiler/test/any.h" | 6 #include "tools/json_schema_compiler/test/any.h" |
6 | 7 |
7 #include "testing/gtest/include/gtest/gtest.h" | |
8 | |
9 using namespace test::api::any; | 8 using namespace test::api::any; |
10 | 9 |
11 TEST(JsonSchemaCompilerAnyTest, AnyTypePopulate) { | 10 TEST(JsonSchemaCompilerAnyTest, AnyTypePopulate) { |
12 { | 11 { |
13 AnyType any_type; | 12 AnyType any_type; |
14 scoped_ptr<DictionaryValue> any_type_value(new DictionaryValue()); | 13 scoped_ptr<DictionaryValue> any_type_value(new DictionaryValue()); |
15 any_type_value->SetString("any", "value"); | 14 any_type_value->SetString("any", "value"); |
16 EXPECT_TRUE(AnyType::Populate(*any_type_value, &any_type)); | 15 EXPECT_TRUE(AnyType::Populate(*any_type_value, &any_type)); |
17 scoped_ptr<Value> any_type_to_value(any_type.ToValue()); | 16 scoped_ptr<Value> any_type_to_value(any_type.ToValue()); |
18 EXPECT_TRUE(any_type_value->Equals(any_type_to_value.get())); | 17 EXPECT_TRUE(any_type_value->Equals(any_type_to_value.get())); |
(...skipping 15 matching lines...) Expand all Loading... |
34 OptionalAny::Params::Create(*params_value)); | 33 OptionalAny::Params::Create(*params_value)); |
35 EXPECT_TRUE(params.get()); | 34 EXPECT_TRUE(params.get()); |
36 EXPECT_FALSE(params->any_name.get()); | 35 EXPECT_FALSE(params->any_name.get()); |
37 } | 36 } |
38 { | 37 { |
39 scoped_ptr<ListValue> params_value(new ListValue()); | 38 scoped_ptr<ListValue> params_value(new ListValue()); |
40 scoped_ptr<Value> param(Value::CreateStringValue("asdf")); | 39 scoped_ptr<Value> param(Value::CreateStringValue("asdf")); |
41 params_value->Append(param->DeepCopy()); | 40 params_value->Append(param->DeepCopy()); |
42 scoped_ptr<OptionalAny::Params> params( | 41 scoped_ptr<OptionalAny::Params> params( |
43 OptionalAny::Params::Create(*params_value)); | 42 OptionalAny::Params::Create(*params_value)); |
44 EXPECT_TRUE(params.get()); | 43 ASSERT_TRUE(params); |
45 EXPECT_TRUE(params->any_name.get()); | 44 ASSERT_TRUE(params->any_name); |
46 EXPECT_TRUE(params->any_name->value().Equals(param.get())); | 45 EXPECT_TRUE(params->any_name->Equals(param.get())); |
47 } | 46 } |
48 { | 47 { |
49 scoped_ptr<ListValue> params_value(new ListValue()); | 48 scoped_ptr<ListValue> params_value(new ListValue()); |
50 scoped_ptr<Value> param(Value::CreateBooleanValue(true)); | 49 scoped_ptr<Value> param(Value::CreateBooleanValue(true)); |
51 params_value->Append(param->DeepCopy()); | 50 params_value->Append(param->DeepCopy()); |
52 scoped_ptr<OptionalAny::Params> params( | 51 scoped_ptr<OptionalAny::Params> params( |
53 OptionalAny::Params::Create(*params_value)); | 52 OptionalAny::Params::Create(*params_value)); |
54 EXPECT_TRUE(params.get()); | 53 ASSERT_TRUE(params); |
55 EXPECT_TRUE(params->any_name.get()); | 54 ASSERT_TRUE(params->any_name); |
56 EXPECT_TRUE(params->any_name.get()); | 55 EXPECT_TRUE(params->any_name->Equals(param.get())); |
57 EXPECT_TRUE(params->any_name->value().Equals(param.get())); | |
58 } | 56 } |
59 } | 57 } |
OLD | NEW |