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

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: reupload Created 8 years, 9 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, 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((size_t) 2, params->info.strings.size());
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 }
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/test/objects.json ('k') | tools/json_schema_compiler/test/simple_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698