diff options
Diffstat (limited to 'src/components/smart_objects/test/ArraySchemaItem_test.cc')
-rw-r--r-- | src/components/smart_objects/test/ArraySchemaItem_test.cc | 90 |
1 files changed, 48 insertions, 42 deletions
diff --git a/src/components/smart_objects/test/ArraySchemaItem_test.cc b/src/components/smart_objects/test/ArraySchemaItem_test.cc index fa42813f8d..9831f08442 100644 --- a/src/components/smart_objects/test/ArraySchemaItem_test.cc +++ b/src/components/smart_objects/test/ArraySchemaItem_test.cc @@ -66,28 +66,29 @@ TEST(test_no_default_value, test_ArraySchemaItemTest) { EXPECT_FALSE(obj[3][1].asBool()); EXPECT_EQ(std::string("Another String"), obj[3][2].asString()); - int resultType = item->validate(obj); + rpc::ValidationReport report("RPC"); + int resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OK, resultType); - resultType = item->validate(obj[0]); + resultType = item->validate(obj[0], &report); EXPECT_EQ(Errors::INVALID_VALUE, resultType); - resultType = item->validate(obj[1]); + resultType = item->validate(obj[1], &report); EXPECT_EQ(Errors::INVALID_VALUE, resultType); - resultType = item->validate(obj[2]); + resultType = item->validate(obj[2], &report); EXPECT_EQ(Errors::INVALID_VALUE, resultType); - resultType = item->validate(obj[3]); + resultType = item->validate(obj[3], &report); EXPECT_EQ(Errors::OK, resultType); item->applySchema(obj, false); - resultType = item->validate(obj); + resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OK, resultType); - resultType = item->validate(obj[0]); + resultType = item->validate(obj[0], &report); EXPECT_EQ(Errors::INVALID_VALUE, resultType); - resultType = item->validate(obj[1]); + resultType = item->validate(obj[1], &report); EXPECT_EQ(Errors::INVALID_VALUE, resultType); - resultType = item->validate(obj[2]); + resultType = item->validate(obj[2], &report); EXPECT_EQ(Errors::INVALID_VALUE, resultType); - resultType = item->validate(obj[3]); + resultType = item->validate(obj[3], &report); EXPECT_EQ(Errors::OK, resultType); EXPECT_EQ(38, obj[0].asInt()); @@ -101,19 +102,19 @@ TEST(test_no_default_value, test_ArraySchemaItemTest) { obj = "New valid string"; ASSERT_EQ(std::string("New valid string"), obj.asString()); - resultType = item->validate(obj); + resultType = item->validate(obj, &report); EXPECT_EQ(Errors::INVALID_VALUE, resultType); // Obj - bool obj = true; - resultType = item->validate(obj); + resultType = item->validate(obj, &report); EXPECT_EQ(Errors::INVALID_VALUE, resultType); // Object - number obj = 3.1415926; - resultType = item->validate(obj); + resultType = item->validate(obj, &report); EXPECT_EQ(Errors::INVALID_VALUE, resultType); } @@ -137,24 +138,25 @@ TEST(test_item_with_default_value, test_ArraySchemaItemTest) { EXPECT_EQ(std::string("true"), obj[1].asString()); EXPECT_EQ(std::string("New String"), obj[2].asString()); - int resultType = item->validate(obj); + rpc::ValidationReport report("RPC"); + int resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OK, resultType); - resultType = item->validate(obj[0]); + resultType = item->validate(obj[0], &report); EXPECT_EQ(Errors::INVALID_VALUE, resultType); - resultType = item->validate(obj[1]); + resultType = item->validate(obj[1], &report); EXPECT_EQ(Errors::INVALID_VALUE, resultType); - resultType = item->validate(obj[2]); + resultType = item->validate(obj[2], &report); EXPECT_EQ(Errors::INVALID_VALUE, resultType); item->applySchema(obj, false); - resultType = item->validate(obj); + resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OK, resultType); - resultType = item->validate(obj[0]); + resultType = item->validate(obj[0], &report); EXPECT_EQ(Errors::INVALID_VALUE, resultType); - resultType = item->validate(obj[1]); + resultType = item->validate(obj[1], &report); EXPECT_EQ(Errors::INVALID_VALUE, resultType); - resultType = item->validate(obj[2]); + resultType = item->validate(obj[2], &report); EXPECT_EQ(Errors::INVALID_VALUE, resultType); EXPECT_EQ(std::string("Some String"), obj[0].asString()); @@ -169,14 +171,14 @@ TEST(test_item_with_default_value, test_ArraySchemaItemTest) { EXPECT_EQ(std::string("false"), obj[3][1].asString()); EXPECT_EQ(std::string("Another String"), obj[3][2].asString()); - resultType = item->validate(obj); + resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OK, resultType); - resultType = item->validate(obj[3]); + resultType = item->validate(obj[3], &report); EXPECT_EQ(Errors::OK, resultType); obj[3][3] = "Another very very loooooong String"; - resultType = item->validate(obj[3]); + resultType = item->validate(obj[3], &report); EXPECT_EQ(Errors::OK, resultType); } @@ -193,17 +195,18 @@ TEST(test_array_with_min_size, test_ArraySchemaItemTest) { obj[0] = "Some String"; - int resultType = item->validate(obj); + rpc::ValidationReport report("RPC"); + int resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OUT_OF_RANGE, resultType); obj[1] = "true"; - resultType = item->validate(obj); + resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OUT_OF_RANGE, resultType); obj[2] = "New String"; - resultType = item->validate(obj); + resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OUT_OF_RANGE, resultType); EXPECT_EQ(std::string("Some String"), obj[0].asString()); @@ -226,22 +229,23 @@ TEST(test_array_with_max_size, test_ArraySchemaItemTest) { obj[0] = "Some String"; - int resultType = item->validate(obj); + rpc::ValidationReport report("RPC"); + int resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OK, resultType); obj[1] = "true"; - resultType = item->validate(obj); + resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OK, resultType); obj[2] = "New String"; - resultType = item->validate(obj); + resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OK, resultType); obj[3] = "Another String"; - resultType = item->validate(obj); + resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OUT_OF_RANGE, resultType); EXPECT_EQ(std::string("Some String"), obj[0].asString()); @@ -265,27 +269,28 @@ TEST(test_array_with_min_and_max_size, test_ArraySchemaItemTest) { obj[0] = "Some String"; - int resultType = item->validate(obj); + rpc::ValidationReport report("RPC"); + int resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OUT_OF_RANGE, resultType); obj[1] = "true"; - resultType = item->validate(obj); + resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OK, resultType); obj[2] = "New String"; - resultType = item->validate(obj); + resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OK, resultType); obj[3] = "Another String"; - resultType = item->validate(obj); + resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OK, resultType); obj[4] = "Out of array"; - resultType = item->validate(obj); + resultType = item->validate(obj, &report); EXPECT_EQ(Errors::OUT_OF_RANGE, resultType); EXPECT_EQ(std::string("Some String"), obj[0].asString()); @@ -307,29 +312,30 @@ TEST(test_map_validate, test_ArraySchemaItemTest) { obj["array"][0] = "Some String"; - int resultType = item->validate(obj["array"]); + rpc::ValidationReport report("RPC"); + int resultType = item->validate(obj["array"], &report); EXPECT_EQ(Errors::OUT_OF_RANGE, resultType); obj["array"][1] = "true"; - resultType = item->validate(obj["array"]); + resultType = item->validate(obj["array"], &report); EXPECT_EQ(Errors::OK, resultType); obj["array"][2] = "New String"; - resultType = item->validate(obj["array"]); + resultType = item->validate(obj["array"], &report); EXPECT_EQ(Errors::OK, resultType); obj["array"][3] = "Another String"; - resultType = item->validate(obj["array"]); + resultType = item->validate(obj["array"], &report); EXPECT_EQ(Errors::OK, resultType); obj["array"][4] = "Out of array"; - resultType = item->validate(obj["array"]); + resultType = item->validate(obj["array"], &report); EXPECT_EQ(Errors::OUT_OF_RANGE, resultType); - resultType = item->validate(obj); + resultType = item->validate(obj, &report); EXPECT_EQ(Errors::INVALID_VALUE, resultType); EXPECT_EQ(std::string("Some String"), obj["array"][0].asString()); |