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; |