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/test/pldmd_registration_test.cpp b/test/pldmd_registration_test.cpp
index 4293357..dbdad5a 100644
--- a/test/pldmd_registration_test.cpp
+++ b/test/pldmd_registration_test.cpp
@@ -33,7 +33,7 @@
TEST(CcOnlyResponse, testEncode)
{
std::vector<uint8_t> requestMsg(sizeof(pldm_msg_hdr));
- auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
+ auto request = new (requestMsg.data()) pldm_msg;
encode_get_types_req(0, request);
auto responseMsg = CmdHandler::ccOnlyResponse(request, PLDM_ERROR);