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..b3001e30554c1254d2c0e0ed6acef7a203ef67f3 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,92 @@ 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(3u, enum_array_reference.types.size()); |
| + |
| + Enumeration expected_types[] = {ENUMERATION_ONE, ENUMERATION_TWO, |
| + ENUMERATION_THREE}; |
| + EXPECT_EQ(std::vector<Enumeration>( |
| + expected_types, expected_types + arraysize(expected_types)), |
| + enum_array_reference.types); |
| + |
| + // 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(3u, enum_array_mixed.inline_enums.size()); |
|
wjywbs
2014/05/16 00:47:37
This is the result of git cl format.
not at google - send to devlin
2014/05/16 17:36:34
ouch.
|
| + EnumArrayMixed::Inline_enumsType expected_inline_types[] = { |
|
not at google - send to devlin
2014/05/16 17:36:34
... but you don't need to assert size if you're do
wjywbs
2014/05/16 19:12:23
Done.
|
| + EnumArrayMixed::INLINE_ENUMS_TYPE_ONE, |
| + EnumArrayMixed::INLINE_ENUMS_TYPE_TWO, |
| + EnumArrayMixed::INLINE_ENUMS_TYPE_THREE}; |
| + EXPECT_EQ(std::vector<EnumArrayMixed::Inline_enumsType>( |
| + expected_inline_types, |
| + expected_inline_types + arraysize(expected_inline_types)), |
| + enum_array_mixed.inline_enums); |
| + |
| + EXPECT_EQ(3u, enum_array_mixed.infile_enums.size()); |
| + Enumeration expected_infile_types[] = {ENUMERATION_ONE, ENUMERATION_TWO, |
| + ENUMERATION_THREE}; |
| + EXPECT_EQ(std::vector<Enumeration>( |
| + expected_infile_types, |
| + expected_infile_types + arraysize(expected_infile_types)), |
| + enum_array_mixed.infile_enums); |
| + |
| + EXPECT_EQ(3u, enum_array_mixed.external_enums.size()); |
| + test::api::enums::Enumeration expected_external_types[] = { |
| + test::api::enums::ENUMERATION_ONE, test::api::enums::ENUMERATION_TWO, |
| + test::api::enums::ENUMERATION_THREE}; |
| + EXPECT_EQ(std::vector<test::api::enums::Enumeration>( |
| + expected_external_types, |
| + expected_external_types + arraysize(expected_external_types)), |
| + enum_array_mixed.external_enums); |
| + |
| + // 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; |