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

Unified Diff: tools/json_schema_compiler/test/any_unittest.cc

Issue 9491002: json_schema_compiler: any, additionalProperties, functions on types (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: add any in arrays to util.h 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/json_schema_compiler/test/any.json ('k') | tools/json_schema_compiler/test/arrays.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/test/any_unittest.cc
diff --git a/tools/json_schema_compiler/test/any_unittest.cc b/tools/json_schema_compiler/test/any_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fc6ae4a320d9faf4b0cc39aec781fe078146e70d
--- /dev/null
+++ b/tools/json_schema_compiler/test/any_unittest.cc
@@ -0,0 +1,59 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "tools/json_schema_compiler/test/any.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+using namespace test::api::any;
+
+TEST(JsonSchemaCompilerAnyTest, AnyTypePopulate) {
+ {
+ AnyType any_type;
+ scoped_ptr<DictionaryValue> any_type_value(new DictionaryValue());
+ any_type_value->SetString("any", "value");
+ EXPECT_TRUE(AnyType::Populate(*any_type_value, &any_type));
+ scoped_ptr<Value> any_type_to_value(any_type.ToValue());
+ EXPECT_TRUE(any_type_value->Equals(any_type_to_value.get()));
+ }
+ {
+ AnyType any_type;
+ scoped_ptr<DictionaryValue> any_type_value(new DictionaryValue());
+ any_type_value->SetInteger("any", 5);
+ EXPECT_TRUE(AnyType::Populate(*any_type_value, &any_type));
+ scoped_ptr<Value> any_type_to_value(any_type.ToValue());
+ EXPECT_TRUE(any_type_value->Equals(any_type_to_value.get()));
+ }
+}
+
+TEST(JsonSchemaCompilerAnyTest, OptionalAnyParamsCreate) {
+ {
+ scoped_ptr<ListValue> params_value(new ListValue());
+ scoped_ptr<OptionalAny::Params> params(
+ OptionalAny::Params::Create(*params_value));
+ EXPECT_TRUE(params.get());
+ EXPECT_FALSE(params->any.get());
+ }
+ {
+ scoped_ptr<ListValue> params_value(new ListValue());
+ scoped_ptr<Value> param(Value::CreateStringValue("asdf"));
+ params_value->Append(param->DeepCopy());
+ scoped_ptr<OptionalAny::Params> params(
+ OptionalAny::Params::Create(*params_value));
+ EXPECT_TRUE(params.get());
+ EXPECT_TRUE(params->any.get());
+ EXPECT_TRUE(params->any->value().Equals(param.get()));
+ }
+ {
+ scoped_ptr<ListValue> params_value(new ListValue());
+ scoped_ptr<Value> param(Value::CreateBooleanValue(true));
+ params_value->Append(param->DeepCopy());
+ scoped_ptr<OptionalAny::Params> params(
+ OptionalAny::Params::Create(*params_value));
+ EXPECT_TRUE(params.get());
+ EXPECT_TRUE(params->any.get());
+ EXPECT_TRUE(params->any.get());
+ EXPECT_TRUE(params->any->value().Equals(param.get()));
+ }
+}
« no previous file with comments | « tools/json_schema_compiler/test/any.json ('k') | tools/json_schema_compiler/test/arrays.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698