regulators: Add test cases for object 'and'.

Test cases for object 'and' are:
*Valid
*Invalid: actions property has incorrect value data type
*Invalid: actions property value is an empty array
*Invalid: actions property value is an array that contains wrong element type

Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: Iec0aa14ce7d0b48bcb1ee5ac3b4a25542180ae6c
diff --git a/phosphor-regulators/test/validate-regulators-config_tests.cpp b/phosphor-regulators/test/validate-regulators-config_tests.cpp
index a352f36..03d5e20 100644
--- a/phosphor-regulators/test/validate-regulators-config_tests.cpp
+++ b/phosphor-regulators/test/validate-regulators-config_tests.cpp
@@ -288,3 +288,63 @@
                             "[] is too short");
     }
 }
+TEST(ValidateRegulatorsConfigTest, And)
+{
+    // Valid.
+    {
+        json configFile = validConfigFile;
+        json andAction =
+            R"(
+                {
+                 "and": [
+                    { "i2c_compare_byte": { "register": "0xA0", "value": "0x00" } },
+                    { "i2c_compare_byte": { "register": "0xA1", "value": "0x00" } }
+                  ]
+                }
+            )"_json;
+        configFile["rules"][0]["actions"].push_back(andAction);
+        EXPECT_JSON_VALID(configFile);
+    }
+
+    // Invalid: actions property value is an empty array.
+    {
+        json configFile = validConfigFile;
+        json andAction =
+            R"(
+                {
+                 "and": []
+                }
+            )"_json;
+        configFile["rules"][0]["actions"].push_back(andAction);
+        EXPECT_JSON_INVALID(configFile, "Validation failed.",
+                            "[] is too short");
+    }
+
+    // Invalid: actions property has incorrect value data type.
+    {
+        json configFile = validConfigFile;
+        json andAction =
+            R"(
+                {
+                 "and": true
+                }
+            )"_json;
+        configFile["rules"][0]["actions"].push_back(andAction);
+        EXPECT_JSON_INVALID(configFile, "Validation failed.",
+                            "True is not of type u'array'");
+    }
+
+    // Invalid: actions property value contains wrong element type
+    {
+        json configFile = validConfigFile;
+        json andAction =
+            R"(
+                {
+                 "and": ["foo"]
+                }
+            )"_json;
+        configFile["rules"][0]["actions"].push_back(andAction);
+        EXPECT_JSON_INVALID(configFile, "Validation failed.",
+                            "u'foo' is not of type u'object'");
+    }
+}