I want to check the validity of the structs stored in the container using gtest. One way of doing it is retrieving the struct and comparing with the expected value. Is there a better way other than this using gtest constructs.
auto receivedflexmessages = m_pugwintegration->getFlexMessages();
EXPECT_EQ(m_expectedflexmessages.size(), receivedflexmessages.size()) << "Mismatch in the received messages";
for (auto i = 0; i < receivedflexmessages.size(); i++)
{
EXPECT_EQ(m_expectedflexmessages[i].m_extId, receivedflexmessages[i].m_extId) << i << "Mismatch in extId";
EXPECT_EQ(m_expectedflexmessages[i].m_handle, receivedflexmessages[i].m_handle) << i << "Mismatch in handle";
EXPECT_EQ(m_expectedflexmessages[i].m_payloadLength, receivedflexmessages[i].m_payloadLength) << i << "Mismatch in payloadlength";
if (m_expectedflexmessages[i].m_payloadLength == receivedflexmessages[i].m_payloadLength)
{
for (auto j = 0; j < m_expectedflexmessages[i].m_payloadLength; ++j)
{
EXPECT_EQ(m_expectedflexmessages[i].m_pPayload[j], receivedflexmessages[i].m_pPayload[j]) << "Payload expected and received differ at index " << j;
}
}
Aucun commentaire:
Enregistrer un commentaire