regulators: Add test cases for object 'not'.
Test cases for object 'not' are:
*Valid: test not.
*Invalid: test not with wrong type.
Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: I4b8f3530c4eb6e1d3b5c4896467d5eb9e3c47863
diff --git a/phosphor-regulators/test/validate-regulators-config_tests.cpp b/phosphor-regulators/test/validate-regulators-config_tests.cpp
index 259ba37..aa77df3 100644
--- a/phosphor-regulators/test/validate-regulators-config_tests.cpp
+++ b/phosphor-regulators/test/validate-regulators-config_tests.cpp
@@ -975,3 +975,23 @@
"1 is not of type u'array'");
}
}
+TEST(ValidateRegulatorsConfigTest, Not)
+{
+ json notFile = validConfigFile;
+ notFile["rules"][0]["actions"][1]["not"]["i2c_compare_byte"]["register"] =
+ "0xA0";
+ notFile["rules"][0]["actions"][1]["not"]["i2c_compare_byte"]["value"] =
+ "0xFF";
+ // Valid: test not.
+ {
+ json configFile = notFile;
+ EXPECT_JSON_VALID(configFile);
+ }
+ // Invalid: test not with wrong type.
+ {
+ json configFile = notFile;
+ configFile["rules"][0]["actions"][1]["not"] = 1;
+ EXPECT_JSON_INVALID(configFile, "Validation failed.",
+ "1 is not of type u'object'");
+ }
+}