tests: Migrate to placement_new from reinterpret casting
reinterpret_cast is prohibited by the C++ core guidelines because
it takes the behavior outside the language definition and gives
problems with type safety. Placement-new on the other-hand allows
to control the object storage while still properly instantiating
an object,keeping the behavior inside the C++ language
specification.
Change-Id: Ifab9ea58b932db11d7af0b9def119bed1bfdc44d
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/libpldmresponder/test/libpldmresponder_bios_integer_attribute_test.cpp b/libpldmresponder/test/libpldmresponder_bios_integer_attribute_test.cpp
index 6d4026a..193ee82 100644
--- a/libpldmresponder/test/libpldmresponder_bios_integer_attribute_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_bios_integer_attribute_test.cpp
@@ -200,8 +200,7 @@
7, 0, 0, 0, 0, 0, 0, 0, /* current value */
};
- auto entry = reinterpret_cast<pldm_bios_attr_val_table_entry*>(
- attrValueEntry.data());
+ auto entry = new (attrValueEntry.data()) pldm_bios_attr_val_table_entry;
EXPECT_CALL(dbusHandler,
setDbusProperty(dbusMapping, PropertyValue{uint8_t(7)}))
.Times(1);