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

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

Issue 10790040: JSON Schema Compiler now supports conversion from Choice to base::Value. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: added comments/style Created 8 years, 5 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/choices_unittest.cc
diff --git a/tools/json_schema_compiler/test/choices_unittest.cc b/tools/json_schema_compiler/test/choices_unittest.cc
index ce5a0ee17ad3ba4adfb3458c8a48574a79827ff5..2cad5a61b87a6c3c26d07d1f1078dc4b1e167d1b 100644
--- a/tools/json_schema_compiler/test/choices_unittest.cc
+++ b/tools/json_schema_compiler/test/choices_unittest.cc
@@ -111,6 +111,40 @@ TEST(JsonSchemaCompilerChoicesTest, ObjectWithChoicesParamsCreateFail) {
}
}
+TEST(JsonSchemaCompilerChoicesTest, PopulateChoiceType) {
+ Value* integers_value = Value::CreateIntegerValue(5);
+ ListValue* strings_value(new ListValue());
not at google - send to devlin 2012/07/18 01:21:35 nit: = new ListValue()
chebert 2012/07/19 00:56:01 Done.
+ strings_value->Append(Value::CreateStringValue("list"));
+ strings_value->Append(Value::CreateStringValue("of"));
+ strings_value->Append(Value::CreateStringValue("strings"));
+
+ scoped_ptr<DictionaryValue> value(new DictionaryValue());
not at google - send to devlin 2012/07/18 01:21:35 value on stack
chebert 2012/07/19 00:56:01 Done.
+ value->Set("integers", integers_value);
not at google - send to devlin 2012/07/18 01:21:35 just inline integers_value here. Should be able to
chebert 2012/07/19 00:56:01 Done.
+ value->Set("strings", strings_value);
+
+ scoped_ptr<ChoiceType> out(new ChoiceType);
not at google - send to devlin 2012/07/18 01:21:35 Just put on stack, use &out rather than out.get()
chebert 2012/07/19 00:56:01 Done.
+ ASSERT_TRUE(ChoiceType::Populate(*value, out.get()));
+ EXPECT_EQ(ChoiceType::INTEGERS_INTEGER, out->integers_type);
+ EXPECT_EQ(ChoiceType::STRINGS_ARRAY, out->strings_type);
not at google - send to devlin 2012/07/18 01:21:35 check values are correct too?
chebert 2012/07/19 00:56:01 Done.
+}
+
+TEST(JsonSchemaCompilerChoicesTest, ChoiceTypeToValue) {
+ Value* integers_value = Value::CreateIntegerValue(5);
+ ListValue* strings_value(new ListValue());
+ strings_value->Append(Value::CreateStringValue("list"));
+ strings_value->Append(Value::CreateStringValue("of"));
+ strings_value->Append(Value::CreateStringValue("strings"));
+
+ scoped_ptr<DictionaryValue> value(new DictionaryValue());
not at google - send to devlin 2012/07/18 01:21:35 ditto value on stack
chebert 2012/07/19 00:56:01 Done.
+ value->Set("integers", integers_value);
not at google - send to devlin 2012/07/18 01:21:35 ditto inline integers_value
chebert 2012/07/19 00:56:01 Done.
+ value->Set("strings", strings_value);
+
+ scoped_ptr<ChoiceType> out(new ChoiceType);
not at google - send to devlin 2012/07/18 01:21:35 ditto ChoiceType()
chebert 2012/07/19 00:56:01 Done.
+ ASSERT_TRUE(ChoiceType::Populate(*value, out.get()));
+
+ EXPECT_TRUE(value->Equals(out->ToValue().get()));
+}
+
TEST(JsonSchemaCompilerChoicesTest, ReturnChoices) {
{
std::vector<int> integers;
« tools/json_schema_compiler/h_generator.py ('K') | « tools/json_schema_compiler/test/choices.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698