Chromium Code Reviews| 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 scoped_ptr<AnyType> any_type(new AnyType()); | |
|
not at google - send to devlin
2012/02/29 03:06:30
just have any_type on the stack
calamity
2012/03/01 04:47:09
Done.
| |
| 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.get())); | |
| 17 EXPECT_TRUE(any_type->any.value().IsType(Value::TYPE_STRING)); | |
|
not at google - send to devlin
2012/02/29 03:06:30
again, try to use Equals rather than all this manu
calamity
2012/03/01 04:47:09
Done.
| |
| 18 std::string temp; | |
| 19 EXPECT_TRUE(any_type->any.value().GetAsString(&temp)); | |
| 20 EXPECT_EQ("value", temp); | |
| 21 } | |
| 22 { | |
| 23 scoped_ptr<AnyType> any_type(new AnyType()); | |
| 24 scoped_ptr<DictionaryValue> any_type_value(new DictionaryValue()); | |
| 25 any_type_value->SetInteger("any", 5); | |
| 26 EXPECT_TRUE(AnyType::Populate(*any_type_value, any_type.get())); | |
| 27 EXPECT_TRUE(any_type->any.value().IsType(Value::TYPE_INTEGER)); | |
| 28 int temp = 0; | |
| 29 EXPECT_TRUE(any_type->any.value().GetAsInteger(&temp)); | |
| 30 EXPECT_EQ(5, temp); | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 TEST(JsonSchemaCompilerAnyTest, OptionalAnyParamsCreate) { | |
| 35 { | |
| 36 scoped_ptr<ListValue> params_value(new ListValue()); | |
| 37 scoped_ptr<OptionalAny::Params> params( | |
| 38 OptionalAny::Params::Create(*params_value)); | |
| 39 EXPECT_TRUE(params.get()); | |
| 40 EXPECT_FALSE(params->any.get()); | |
| 41 } | |
| 42 { | |
| 43 scoped_ptr<ListValue> params_value(new ListValue()); | |
| 44 params_value->Append(Value::CreateStringValue("asdf")); | |
| 45 scoped_ptr<OptionalAny::Params> params( | |
| 46 OptionalAny::Params::Create(*params_value)); | |
| 47 EXPECT_TRUE(params.get()); | |
| 48 EXPECT_TRUE(params->any.get()); | |
| 49 EXPECT_TRUE(params->any->value().IsType(Value::TYPE_STRING)); | |
| 50 std::string temp; | |
| 51 EXPECT_TRUE(params->any->value().GetAsString(&temp)); | |
| 52 EXPECT_EQ("asdf", temp); | |
| 53 } | |
| 54 { | |
| 55 scoped_ptr<ListValue> params_value(new ListValue()); | |
| 56 params_value->Append(Value::CreateBooleanValue(true)); | |
| 57 scoped_ptr<OptionalAny::Params> params( | |
| 58 OptionalAny::Params::Create(*params_value)); | |
| 59 EXPECT_TRUE(params.get()); | |
| 60 EXPECT_TRUE(params->any.get()); | |
| 61 EXPECT_TRUE(params->any->value().IsType(Value::TYPE_BOOLEAN)); | |
| 62 bool temp; | |
| 63 EXPECT_TRUE(params->any->value().GetAsBoolean(&temp)); | |
| 64 EXPECT_TRUE(temp); | |
| 65 } | |
| 66 } | |
| OLD | NEW |