OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "tools/json_schema_compiler/test/any.h" |
| 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 |
| 9 using namespace test::api::any; |
| 10 |
| 11 TEST(JsonSchemaCompilerAnyTest, AnyTypePopulate) { |
| 12 { |
| 13 AnyType any_type; |
| 14 scoped_ptr<DictionaryValue> any_type_value(new DictionaryValue()); |
| 15 any_type_value->SetString("any", "value"); |
| 16 EXPECT_TRUE(AnyType::Populate(*any_type_value, &any_type)); |
| 17 scoped_ptr<Value> any_type_to_value(any_type.ToValue()); |
| 18 EXPECT_TRUE(any_type_value->Equals(any_type_to_value.get())); |
| 19 } |
| 20 { |
| 21 AnyType any_type; |
| 22 scoped_ptr<DictionaryValue> any_type_value(new DictionaryValue()); |
| 23 any_type_value->SetInteger("any", 5); |
| 24 EXPECT_TRUE(AnyType::Populate(*any_type_value, &any_type)); |
| 25 scoped_ptr<Value> any_type_to_value(any_type.ToValue()); |
| 26 EXPECT_TRUE(any_type_value->Equals(any_type_to_value.get())); |
| 27 } |
| 28 } |
| 29 |
| 30 TEST(JsonSchemaCompilerAnyTest, OptionalAnyParamsCreate) { |
| 31 { |
| 32 scoped_ptr<ListValue> params_value(new ListValue()); |
| 33 scoped_ptr<OptionalAny::Params> params( |
| 34 OptionalAny::Params::Create(*params_value)); |
| 35 EXPECT_TRUE(params.get()); |
| 36 EXPECT_FALSE(params->any.get()); |
| 37 } |
| 38 { |
| 39 scoped_ptr<ListValue> params_value(new ListValue()); |
| 40 scoped_ptr<Value> param(Value::CreateStringValue("asdf")); |
| 41 params_value->Append(param->DeepCopy()); |
| 42 scoped_ptr<OptionalAny::Params> params( |
| 43 OptionalAny::Params::Create(*params_value)); |
| 44 EXPECT_TRUE(params.get()); |
| 45 EXPECT_TRUE(params->any.get()); |
| 46 EXPECT_TRUE(params->any->value().Equals(param.get())); |
| 47 } |
| 48 { |
| 49 scoped_ptr<ListValue> params_value(new ListValue()); |
| 50 scoped_ptr<Value> param(Value::CreateBooleanValue(true)); |
| 51 params_value->Append(param->DeepCopy()); |
| 52 scoped_ptr<OptionalAny::Params> params( |
| 53 OptionalAny::Params::Create(*params_value)); |
| 54 EXPECT_TRUE(params.get()); |
| 55 EXPECT_TRUE(params->any.get()); |
| 56 EXPECT_TRUE(params->any.get()); |
| 57 EXPECT_TRUE(params->any->value().Equals(param.get())); |
| 58 } |
| 59 } |
OLD | NEW |