Replace sizeof() with .size()
This change replaces the usage of sizeof() with .size() to
calculate size of arrays and expressions of STL container types.
Using .size() with containers like std::vector, std::array, and
std::string improves code readability and adheres to modern C++
standards. This also helps in clang-tidy checks.
Change-Id: I1e9e6e453a3b9218682098887763a4908f186815
Signed-off-by: Pavithra Barithaya <pavithra.b@ibm.com>
diff --git a/requester/test/handler_test.cpp b/requester/test/handler_test.cpp
index 3b003a0..fcc417f 100644
--- a/requester/test/handler_test.cpp
+++ b/requester/test/handler_test.cpp
@@ -87,7 +87,7 @@
pldm::Response response(sizeof(pldm_msg_hdr) + sizeof(uint8_t));
auto responsePtr = reinterpret_cast<const pldm_msg*>(response.data());
reqHandler.handleResponse(eid, instanceId, 0, 0, responsePtr,
- sizeof(response));
+ response.size());
EXPECT_EQ(validResponse, true);
}
@@ -135,7 +135,7 @@
pldm::Response response(sizeof(pldm_msg_hdr) + sizeof(uint8_t));
auto responsePtr = reinterpret_cast<const pldm_msg*>(response.data());
reqHandler.handleResponse(eid, instanceId, 0, 0, responsePtr,
- sizeof(response));
+ response.size());
EXPECT_EQ(validResponse, true);
EXPECT_EQ(callbackCount, 1);
validResponse = false;
@@ -145,7 +145,7 @@
waitEventExpiry(milliseconds(500));
reqHandler.handleResponse(eid, instanceIdNxt, 0, 0, responsePtr,
- sizeof(response));
+ response.size());
EXPECT_EQ(validResponse, true);
EXPECT_EQ(callbackCount, 2);