Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Side by Side Diff: tools/json_schema_compiler/test/objects_unittest.cc

Issue 9456007: Add wider support to json_schema_compiler (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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, ReturnsObjectResultCreate) {
Yoyo Zhou 2012/02/24 04:02:22 nit: these tests seem to be in reverse order
calamity 2012/02/24 15:10:40 Done.
12 scoped_ptr<ReturnsObject::Result::Info> info(
13 new ReturnsObject::Result::Info());
14 info->state = ReturnsObject::Result::Info::STATE_FOO;
15 scoped_ptr<Value> result_value(
16 ReturnsObject::Result::Create(*info));
17 DictionaryValue* result_dict = NULL;
18 EXPECT_TRUE(result_value->GetAsDictionary(&result_dict));
19 std::string state;
20 EXPECT_TRUE(result_dict->GetString("state", &state));
21 EXPECT_EQ("foo", state);
22 }
23
24 TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) {
25 {
26 scoped_ptr<ListValue> strings(new ListValue());
27 strings->Append(Value::CreateStringValue("one"));
28 strings->Append(Value::CreateStringValue("two"));
29 scoped_ptr<DictionaryValue> info_value(new DictionaryValue());
30 info_value->Set("strings", strings.release());
31 info_value->Set("integer", Value::CreateIntegerValue(5));
32 info_value->Set("boolean", Value::CreateBooleanValue(true));
33
34 scoped_ptr<ListValue> params_value(new ListValue());
35 params_value->Append(info_value.release());
36 scoped_ptr<ObjectParam::Params> params(
37 ObjectParam::Params::Create(*params_value));
38 EXPECT_TRUE(params.get());
39 EXPECT_EQ(2, params->info.strings.size());
40 EXPECT_EQ("one", params->info.strings[0]);
41 EXPECT_EQ("two", params->info.strings[1]);
42 EXPECT_EQ(5, params->info.integer);
43 EXPECT_TRUE(params->info.boolean);
44 }
45 {
46 scoped_ptr<ListValue> strings(new ListValue());
47 strings->Append(Value::CreateStringValue("one"));
48 strings->Append(Value::CreateStringValue("two"));
49 scoped_ptr<DictionaryValue> info_value(new DictionaryValue());
50 info_value->Set("strings", strings.release());
51 info_value->Set("integer", Value::CreateIntegerValue(5));
52
53 scoped_ptr<ListValue> params_value(new ListValue());
54 params_value->Append(info_value.release());
55 scoped_ptr<ObjectParam::Params> params(
56 ObjectParam::Params::Create(*params_value));
57 EXPECT_FALSE(params.get());
58 }
59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698