Chromium Code Reviews| Index: tools/json_schema_compiler/test/arrays_unittest.cc |
| diff --git a/tools/json_schema_compiler/test/arrays_unittest.cc b/tools/json_schema_compiler/test/arrays_unittest.cc |
| index 9aca730db38835fc5596b49b56cfdfc36f7113b9..9e289055c3cf52e3c5c636ddbbea14482056ec3b 100644 |
| --- a/tools/json_schema_compiler/test/arrays_unittest.cc |
| +++ b/tools/json_schema_compiler/test/arrays_unittest.cc |
| @@ -5,6 +5,7 @@ |
| #include "tools/json_schema_compiler/test/arrays.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| +#include "tools/json_schema_compiler/test/enums.h" |
| using namespace test::api::arrays; |
| @@ -80,6 +81,77 @@ TEST(JsonSchemaCompilerArrayTest, EnumArrayType) { |
| EXPECT_TRUE(value.Equals(as_value.get())) << value << " != " << *as_value; |
| } |
| +TEST(JsonSchemaCompilerArrayTest, EnumArrayReference) { |
| + // { "types": ["one", "two", "three"] } |
| + base::ListValue* types = new base::ListValue(); |
| + types->AppendString("one"); |
| + types->AppendString("two"); |
| + types->AppendString("three"); |
| + base::DictionaryValue value; |
| + value.Set("types", types); |
| + |
| + EnumArrayReference enum_array_reference; |
| + |
| + // Test Populate. |
| + ASSERT_TRUE(EnumArrayReference::Populate(value, &enum_array_reference)); |
| + EXPECT_EQ(enum_array_reference.types.at(0), ENUMERATION_ONE); |
|
not at google - send to devlin
2014/05/14 22:52:45
- assert correct size
- use [0] not .at(0)
you ca
|
| + EXPECT_EQ(enum_array_reference.types.at(1), ENUMERATION_TWO); |
| + EXPECT_EQ(enum_array_reference.types.at(2), ENUMERATION_THREE); |
| + |
| + // Test ToValue. |
| + scoped_ptr<base::Value> as_value(enum_array_reference.ToValue()); |
| + EXPECT_TRUE(value.Equals(as_value.get())) << value << " != " << *as_value; |
| +} |
| + |
| +TEST(JsonSchemaCompilerArrayTest, EnumArrayMixed) { |
| + // { "types": ["one", "two", "three"] } |
| + base::ListValue* inline_enums = new base::ListValue(); |
| + inline_enums->AppendString("one"); |
| + inline_enums->AppendString("two"); |
| + inline_enums->AppendString("three"); |
| + |
| + base::ListValue* infile_enums = new base::ListValue(); |
| + infile_enums->AppendString("one"); |
| + infile_enums->AppendString("two"); |
| + infile_enums->AppendString("three"); |
| + |
| + base::ListValue* external_enums = new base::ListValue(); |
| + external_enums->AppendString("one"); |
| + external_enums->AppendString("two"); |
| + external_enums->AppendString("three"); |
| + |
| + base::DictionaryValue value; |
| + value.Set("inline_enums", inline_enums); |
| + value.Set("infile_enums", infile_enums); |
| + value.Set("external_enums", external_enums); |
| + |
| + EnumArrayMixed enum_array_mixed; |
| + |
| + // Test Populate. |
| + ASSERT_TRUE(EnumArrayMixed::Populate(value, &enum_array_mixed)); |
| + EXPECT_EQ(enum_array_mixed.inline_enums.at(0), |
| + EnumArrayMixed::INLINE_ENUMS_TYPE_ONE); |
| + EXPECT_EQ(enum_array_mixed.inline_enums.at(1), |
| + EnumArrayMixed::INLINE_ENUMS_TYPE_TWO); |
| + EXPECT_EQ(enum_array_mixed.inline_enums.at(2), |
| + EnumArrayMixed::INLINE_ENUMS_TYPE_THREE); |
| + |
| + EXPECT_EQ(enum_array_mixed.infile_enums.at(0), ENUMERATION_ONE); |
| + EXPECT_EQ(enum_array_mixed.infile_enums.at(1), ENUMERATION_TWO); |
| + EXPECT_EQ(enum_array_mixed.infile_enums.at(2), ENUMERATION_THREE); |
| + |
| + EXPECT_EQ(enum_array_mixed.external_enums.at(0), |
| + test::api::enums::ENUMERATION_ONE); |
| + EXPECT_EQ(enum_array_mixed.external_enums.at(1), |
| + test::api::enums::ENUMERATION_TWO); |
| + EXPECT_EQ(enum_array_mixed.external_enums.at(2), |
| + test::api::enums::ENUMERATION_THREE); |
| + |
| + // Test ToValue. |
| + scoped_ptr<base::Value> as_value(enum_array_mixed.ToValue()); |
| + EXPECT_TRUE(value.Equals(as_value.get())) << value << " != " << *as_value; |
| +} |
| + |
| TEST(JsonSchemaCompilerArrayTest, OptionalEnumArrayType) { |
| { |
| std::vector<OptionalEnumArrayType::TypesType> enums; |