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/additionalProperties.h" | |
| 6 | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 | |
| 9 using namespace test::api::additional_properties; | |
| 10 | |
| 11 TEST(JsonSchemaCompilerAdditionalPropertiesTest, | |
| 12 AdditionalPropertiesParamsCreate) { | |
| 13 scoped_ptr<DictionaryValue> param_object_value(new DictionaryValue()); | |
| 14 param_object_value->SetString("str", "a"); | |
| 15 param_object_value->SetInteger("num", 1); | |
| 16 scoped_ptr<ListValue> params_value(new ListValue()); | |
| 17 params_value->Append(param_object_value.release()); | |
| 18 scoped_ptr<AdditionalProperties::Params> params( | |
| 19 AdditionalProperties::Params::Create(*params_value)); | |
| 20 EXPECT_TRUE(params.get()); | |
| 21 int int_temp = 0; | |
|
not at google - send to devlin
2012/02/29 03:06:30
you could replace all of this to the bottom with
calamity
2012/03/01 04:47:09
Done.
not at google - send to devlin
2012/03/01 07:09:37
param_object_value still isn't on the stack... I m
| |
| 22 EXPECT_TRUE(params->param_object.additional_properties.GetInteger( | |
| 23 "num", &int_temp)); | |
| 24 EXPECT_EQ(1, int_temp); | |
| 25 std::string string_temp; | |
| 26 EXPECT_TRUE(params->param_object.additional_properties.GetString( | |
| 27 "str", &string_temp)); | |
| 28 EXPECT_EQ("a", string_temp); | |
| 29 } | |
| 30 | |
| 31 TEST(JsonSchemaCompilerAdditionalPropertiesTest, | |
| 32 ReturnAdditionalPropertiesResultCreate) { | |
| 33 scoped_ptr<DictionaryValue> result_object_value(new DictionaryValue()); | |
| 34 result_object_value->SetString("key", "value"); | |
| 35 scoped_ptr<ReturnAdditionalProperties::Result::ResultObject> result_object( | |
| 36 new ReturnAdditionalProperties::Result::ResultObject()); | |
| 37 result_object->integer = 5; | |
| 38 result_object->additional_properties.MergeDictionary( | |
| 39 result_object_value.get()); | |
| 40 scoped_ptr<Value> result( | |
| 41 ReturnAdditionalProperties::Result::Create(*result_object)); | |
| 42 DictionaryValue* result_dict = NULL; | |
|
not at google - send to devlin
2012/02/29 03:06:30
same comment as above, try to use Equals on the va
calamity
2012/03/01 04:47:09
Done.
| |
| 43 EXPECT_TRUE(result->GetAsDictionary(&result_dict)); | |
| 44 std::string string_temp; | |
| 45 EXPECT_TRUE(result_dict->GetString("key", &string_temp)); | |
| 46 EXPECT_EQ("value", string_temp); | |
| 47 int int_temp; | |
| 48 EXPECT_TRUE(result_dict->GetInteger("integer", &int_temp)); | |
| 49 EXPECT_EQ(5, int_temp); | |
| 50 } | |
| OLD | NEW |