bios: add getValueIndex unit test coverage

Add unit tests for BIOSEnumAttribute::getValueIndex() to
cover both successful value lookups and invalid input
handling.

Verify that valid enumeration values return the expected
indices and that unknown values continue to throw
std::invalid_argument.

Change-Id: If2efb201d60e8bc1e81d250842c3b5dda7c69c05
Signed-off-by: Meghana Vangapandu <meghanav@ami.com>
diff --git a/libpldmresponder/test/libpldmresponder_bios_enum_attribute_test.cpp b/libpldmresponder/test/libpldmresponder_bios_enum_attribute_test.cpp
index 34a62b9..435f312 100644
--- a/libpldmresponder/test/libpldmresponder_bios_enum_attribute_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_bios_enum_attribute_test.cpp
@@ -28,6 +28,13 @@
     {
         return attribute.defaultValue;
     }
+
+    uint8_t getValueIndex(BIOSEnumAttribute& attribute,
+                          const std::string& value,
+                          const std::vector<std::string>& pVs)
+    {
+        return attribute.getValueIndex(value, pVs);
+    }
 };
 
 TEST_F(TestBIOSEnumAttribute, CtorTest)
@@ -234,3 +241,39 @@
         new (attrValueEntry.data()) pldm_bios_attr_val_table_entry,
         new (attrEntry.data()) pldm_bios_attr_table_entry, biosStringTable);
 }
+
+TEST_F(TestBIOSEnumAttribute, GetValueIndexThrowsOnUnknownValue)
+{
+    auto json = R"({
+         "attribute_name" : "CodeUpdatePolicy",
+         "possible_values" : [ "Concurrent", "Disruptive" ],
+         "value_names" : [ "Concurrent", "Disruptive" ],
+         "default_values" : [ "Concurrent" ],
+         "read_only" : true,
+         "help_text" : "HelpText",
+         "display_name" : "DisplayName"
+      })"_json;
+
+    BIOSEnumAttribute attr{json, nullptr};
+    EXPECT_THROW(getValueIndex(attr, "unknown", {"Concurrent", "Disruptive"}),
+                 std::invalid_argument);
+}
+
+TEST_F(TestBIOSEnumAttribute, GetValueIndexReturnsCorrectIndex)
+{
+    auto json = R"({
+         "attribute_name" : "CodeUpdatePolicy",
+         "possible_values" : [ "Concurrent", "Disruptive" ],
+         "value_names" : [ "Concurrent", "Disruptive" ],
+         "default_values" : [ "Concurrent" ],
+         "read_only" : true,
+         "help_text" : "HelpText",
+         "display_name" : "DisplayName"
+      })"_json;
+
+    BIOSEnumAttribute attr{json, nullptr};
+    EXPECT_EQ(getValueIndex(attr, "Concurrent", {"Concurrent", "Disruptive"}),
+              0);
+    EXPECT_EQ(getValueIndex(attr, "Disruptive", {"Concurrent", "Disruptive"}),
+              1);
+}