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/objects.h" | |
| 6 | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 | |
| 9 using namespace test::api::objects; | |
| 10 | |
| 11 TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) { | |
| 12 { | |
| 13 scoped_ptr<ListValue> strings(new ListValue()); | |
| 14 strings->Append(Value::CreateStringValue("one")); | |
| 15 strings->Append(Value::CreateStringValue("two")); | |
| 16 scoped_ptr<DictionaryValue> info_value(new DictionaryValue()); | |
| 17 info_value->Set("strings", strings.release()); | |
| 18 info_value->Set("integer", Value::CreateIntegerValue(5)); | |
| 19 info_value->Set("boolean", Value::CreateBooleanValue(true)); | |
| 20 | |
| 21 scoped_ptr<ListValue> params_value(new ListValue()); | |
| 22 params_value->Append(info_value.release()); | |
| 23 scoped_ptr<ObjectParam::Params> params( | |
| 24 ObjectParam::Params::Create(*params_value)); | |
| 25 EXPECT_TRUE(params.get()); | |
| 26 EXPECT_EQ(2UL, params->info.strings.size()); | |
|
not at google - send to devlin
2012/02/26 23:51:53
This may cause size problems on other platforms wh
calamity
2012/02/27 04:57:30
Done.
not at google - send to devlin
2012/02/27 06:04:47
nit: space between (size_t) and 2.
Yoyo Zhou
2012/02/28 00:29:46
2U is pretty common, I don't think you need this c
| |
| 27 EXPECT_EQ("one", params->info.strings[0]); | |
| 28 EXPECT_EQ("two", params->info.strings[1]); | |
| 29 EXPECT_EQ(5, params->info.integer); | |
| 30 EXPECT_TRUE(params->info.boolean); | |
| 31 } | |
| 32 { | |
| 33 scoped_ptr<ListValue> strings(new ListValue()); | |
| 34 strings->Append(Value::CreateStringValue("one")); | |
| 35 strings->Append(Value::CreateStringValue("two")); | |
| 36 scoped_ptr<DictionaryValue> info_value(new DictionaryValue()); | |
| 37 info_value->Set("strings", strings.release()); | |
| 38 info_value->Set("integer", Value::CreateIntegerValue(5)); | |
| 39 | |
| 40 scoped_ptr<ListValue> params_value(new ListValue()); | |
| 41 params_value->Append(info_value.release()); | |
| 42 scoped_ptr<ObjectParam::Params> params( | |
| 43 ObjectParam::Params::Create(*params_value)); | |
| 44 EXPECT_FALSE(params.get()); | |
| 45 } | |
| 46 } | |
| 47 | |
| 48 TEST(JsonSchemaCompilerObjectsTest, ReturnsObjectResultCreate) { | |
| 49 scoped_ptr<ReturnsObject::Result::Info> info( | |
| 50 new ReturnsObject::Result::Info()); | |
| 51 info->state = ReturnsObject::Result::Info::STATE_FOO; | |
| 52 scoped_ptr<Value> result_value( | |
| 53 ReturnsObject::Result::Create(*info)); | |
| 54 DictionaryValue* result_dict = NULL; | |
| 55 EXPECT_TRUE(result_value->GetAsDictionary(&result_dict)); | |
| 56 std::string state; | |
| 57 EXPECT_TRUE(result_dict->GetString("state", &state)); | |
| 58 EXPECT_EQ("foo", state); | |
| 59 } | |
| OLD | NEW |