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

Unified Diff: tools/json_schema_compiler/test/additional_properties_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: remove whitespace 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
Index: tools/json_schema_compiler/test/additional_properties_unittest.cc
diff --git a/tools/json_schema_compiler/test/additional_properties_unittest.cc b/tools/json_schema_compiler/test/additional_properties_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2f1327d77e994ae0ccd9d1f3bd0081d36694cb3e
--- /dev/null
+++ b/tools/json_schema_compiler/test/additional_properties_unittest.cc
@@ -0,0 +1,50 @@
+// 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/additionalProperties.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+using namespace test::api::additional_properties;
+
+TEST(JsonSchemaCompilerAdditionalPropertiesTest,
+ AdditionalPropertiesParamsCreate) {
+ scoped_ptr<DictionaryValue> param_object_value(new DictionaryValue());
+ param_object_value->SetString("str", "a");
+ param_object_value->SetInteger("num", 1);
+ scoped_ptr<ListValue> params_value(new ListValue());
+ params_value->Append(param_object_value.release());
+ scoped_ptr<AdditionalProperties::Params> params(
+ AdditionalProperties::Params::Create(*params_value));
+ EXPECT_TRUE(params.get());
+ 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
+ EXPECT_TRUE(params->param_object.additional_properties.GetInteger(
+ "num", &int_temp));
+ EXPECT_EQ(1, int_temp);
+ std::string string_temp;
+ EXPECT_TRUE(params->param_object.additional_properties.GetString(
+ "str", &string_temp));
+ EXPECT_EQ("a", string_temp);
+}
+
+TEST(JsonSchemaCompilerAdditionalPropertiesTest,
+ ReturnAdditionalPropertiesResultCreate) {
+ scoped_ptr<DictionaryValue> result_object_value(new DictionaryValue());
+ result_object_value->SetString("key", "value");
+ scoped_ptr<ReturnAdditionalProperties::Result::ResultObject> result_object(
+ new ReturnAdditionalProperties::Result::ResultObject());
+ result_object->integer = 5;
+ result_object->additional_properties.MergeDictionary(
+ result_object_value.get());
+ scoped_ptr<Value> result(
+ ReturnAdditionalProperties::Result::Create(*result_object));
+ 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.
+ EXPECT_TRUE(result->GetAsDictionary(&result_dict));
+ std::string string_temp;
+ EXPECT_TRUE(result_dict->GetString("key", &string_temp));
+ EXPECT_EQ("value", string_temp);
+ int int_temp;
+ EXPECT_TRUE(result_dict->GetInteger("integer", &int_temp));
+ EXPECT_EQ(5, int_temp);
+}

Powered by Google App Engine
This is Rietveld 408576698