Support numeric effecters in dbus-to-host-effecter

Adds support of the numeric effecter PDR (section `28.11 Numeric
Effecter PDR` DSP0248 V1.3.0) type in dbus-to-host-effecter handler.
This handler will be applied for all PLDM termini but not only host.
The setting for one numeric effecter of one device can be:
{
    "mctp_eid": 20,
    "effecter_info": {
        "effecterPdrType": 9,
        "effecterID": 2,
        "entityType": 32903,
        "entityInstance": 2,
        "containerID": 2,
        "compositeEffecterCount": 1,
        "checkHostState": false
    },
    "effecters": [
        {
            "dbus_info": {
                "object_path": "/xyz/openbmc_project/sensors/power/A",
                "interface": "xyz.openbmc_project.Sensor.Value",
                "property_name": "Value",
                "property_type": "double"
            },
            "effecterDataSize": 5,
            "resolution": 1,
            "offset": 0,
            "unitModifier": 0
        }
    ]
}

Where:
+ effecterPdrType to difference state/numeric effecter type. Default
is state effecter.
+ effecterID should be effecter ID and should not empty.
+ checkHostState can be set to false to bypass checking host state.
+ effecterDataSize, resolution, offset, unitModifier are from numeric
effecter PDR (section `28.11 Numeric Effecter PDR` DSP0248 V1.3.0)

Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: I438d7f204643edd4066e8a6ba28d53a97503fc4b
diff --git a/common/test/pldm_utils_test.cpp b/common/test/pldm_utils_test.cpp
index d00bebd..bab64fc 100644
--- a/common/test/pldm_utils_test.cpp
+++ b/common/test/pldm_utils_test.cpp
@@ -1090,3 +1090,69 @@
     result = trimNameForDbus(name);
     EXPECT_EQ(expectedName, result);
 }
+
+TEST(dbusPropValuesToDouble, goodTest)
+{
+    double value = 0;
+    bool ret =
+        dbusPropValuesToDouble("uint8_t", static_cast<uint8_t>(0x12), &value);
+    EXPECT_EQ(true, ret);
+    EXPECT_EQ(0x12, value);
+    ret =
+        dbusPropValuesToDouble("int16_t", static_cast<int16_t>(0x1234), &value);
+    EXPECT_EQ(true, ret);
+    EXPECT_EQ(0x1234, value);
+    ret = dbusPropValuesToDouble("uint16_t", static_cast<uint16_t>(0x8234),
+                                 &value);
+    EXPECT_EQ(true, ret);
+    EXPECT_EQ(0x8234, value);
+    ret = dbusPropValuesToDouble("int32_t", static_cast<int32_t>(0x12345678),
+                                 &value);
+    EXPECT_EQ(true, ret);
+    EXPECT_EQ(0x12345678, value);
+    ret = dbusPropValuesToDouble("uint32_t", static_cast<uint32_t>(0x82345678),
+                                 &value);
+    EXPECT_EQ(true, ret);
+    EXPECT_EQ(0x82345678, value);
+    ret = dbusPropValuesToDouble(
+        "int64_t", static_cast<int64_t>(0x1234567898765432), &value);
+    EXPECT_EQ(true, ret);
+    EXPECT_EQ(0x1234567898765432, value);
+    ret = dbusPropValuesToDouble(
+        "uint64_t", static_cast<uint64_t>(0x8234567898765432), &value);
+    EXPECT_EQ(true, ret);
+    EXPECT_EQ(0x8234567898765432, value);
+    ret = dbusPropValuesToDouble("double", static_cast<double>(1234.5678),
+                                 &value);
+    EXPECT_EQ(true, ret);
+    EXPECT_EQ(1234.5678, value);
+}
+
+TEST(dbusPropValuesToDouble, badTest)
+{
+    double value = std::numeric_limits<double>::quiet_NaN();
+    /* Type and Data variant are different */
+    bool ret =
+        dbusPropValuesToDouble("uint8_t", static_cast<uint16_t>(0x12), &value);
+    EXPECT_EQ(false, ret);
+    /* Unsupported Types */
+    ret = dbusPropValuesToDouble("string", static_cast<std::string>("hello"),
+                                 &value);
+    EXPECT_EQ(false, ret);
+    ret = dbusPropValuesToDouble("bool", static_cast<bool>(true), &value);
+    EXPECT_EQ(false, ret);
+    ret = dbusPropValuesToDouble("vector<uint8_t>",
+                                 static_cast<std::string>("hello"), &value);
+    EXPECT_EQ(false, ret);
+    ret = dbusPropValuesToDouble("vector<string>",
+                                 static_cast<std::string>("hello"), &value);
+    EXPECT_EQ(false, ret);
+    /* Support Type but Data Type is unsupported */
+    ret = dbusPropValuesToDouble("double", static_cast<std::string>("hello"),
+                                 &value);
+    EXPECT_EQ(false, ret);
+    /* Null pointer */
+    ret = dbusPropValuesToDouble("double", static_cast<std::string>("hello"),
+                                 nullptr);
+    EXPECT_EQ(false, ret);
+}