Skip to content

Commit

Permalink
Replace EXPECT_TRUE with EXPECT_EQ (#318)
Browse files Browse the repository at this point in the history
EXPECT_EQ provide more information in most of cases on fail.

Signed-off-by: Cervenka Dusan <cervenka@acrios.com>

Signed-off-by: Cervenka Dusan <cervenka@acrios.com>
  • Loading branch information
Hadatko authored Oct 6, 2022
1 parent c313d54 commit 02541cd
Show file tree
Hide file tree
Showing 14 changed files with 159 additions and 159 deletions.
4 changes: 2 additions & 2 deletions test/common/gtestListener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class LeakChecker : public ::testing::EmptyTestEventListener
{
int serverAlloc = getServerAllocated();

EXPECT_TRUE(MyAlloc::allocated() == 0)
EXPECT_EQ(MyAlloc::allocated(), 0)
<< "Leaked (on client side) : " << MyAlloc::allocated() << " unit(s) need be freed!";
EXPECT_TRUE(serverAlloc == 0) << "Leaked (on server side) : " << serverAlloc << " unit(s) need be freed!";
EXPECT_EQ(serverAlloc, 0) << "Leaked (on server side) : " << serverAlloc << " unit(s) need be freed!";
MyAlloc::allocated(0);
}
};
Expand Down
8 changes: 4 additions & 4 deletions test/test_annotations/test_annotations_client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@

TEST(test_annotations, AnnotationServiceID)
{
EXPECT_TRUE(5 == kAnnotateTest_service_id);
EXPECT_EQ(kAnnotateTest_service_id, 5);
}

TEST(test_annotations, IncludeAnnotationCheck)
{
EXPECT_TRUE(5 == addOne(4));
EXPECT_EQ(addOne(4), 5);

includedInt_t testInt = 5;
EXPECT_TRUE(5 == testInt);
EXPECT_EQ(testInt, 5);
}

TEST(test_annotations, testIfMyIntAndConstExist)
{
EXPECT_TRUE(i == testIfMyIntAndConstExist(i));
EXPECT_EQ(i, testIfMyIntAndConstExist(i));
}
8 changes: 4 additions & 4 deletions test/test_arbitrator/test_arbitrator_client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TEST(test_arbitrator, FirstSendReceiveInt)
for (int i = number - 1; i >= 0; i--)
{
int b = firstReceiveInt();
EXPECT_TRUE(i == b);
EXPECT_EQ(i, b);
}
}

Expand All @@ -45,7 +45,7 @@ TEST(test_arbitrator, FirstSendReceiveInt2)
for (int i = number - 1; i >= 0; i--)
{
int b = firstReceiveInt();
EXPECT_TRUE(i == b);
EXPECT_EQ(i, b);
}
}

Expand All @@ -55,12 +55,12 @@ TEST(test_arbitrator, NestedCallTest)
while (!enabled)
{
};
EXPECT_TRUE(nestedCallTest() == nestedCallsCount * 2 - 1);
EXPECT_EQ(nestedCallTest(), nestedCallsCount * 2 - 1);
}

TEST(test_arbitrator, GetResultFromSecondSide)
{
EXPECT_TRUE(getResultFromSecondSide() == 0);
EXPECT_EQ(getResultFromSecondSide(), 0);
}

TEST(test_arbitrator, testCasesAreDone)
Expand Down
72 changes: 36 additions & 36 deletions test/test_arrays/test_arrays_client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ TEST(test_arrays, sendReceivedInt32)

for (uint32_t i = 0; i < array_count; ++i)
{
EXPECT_TRUE(send_array[i] == (*received_array)[i]);
EXPECT_EQ(send_array[i], (*received_array)[i]);
}
erpc_free(received_array);
}
Expand All @@ -53,7 +53,7 @@ TEST(test_arrays, sendReceived2Int32)
{
for (uint32_t j = 0; j < 10; ++j)
{
EXPECT_TRUE(send_array[i][j] == (*received_array)[i][j]);
EXPECT_EQ(send_array[i][j], (*received_array)[i][j]);
}
}
erpc_free(received_array);
Expand Down Expand Up @@ -130,7 +130,7 @@ TEST(test_arrays, sendReceivedEnum)

for (uint32_t i = 0; i < array_count; ++i)
{
EXPECT_TRUE(send_array[i] == (*received_array)[i]);
EXPECT_EQ(send_array[i], (*received_array)[i]);
}
erpc_free(received_array);
}
Expand All @@ -154,7 +154,7 @@ TEST(test_arrays, sendReceived2Enum)
{
for (uint32_t j = 0; j < 3; ++j)
{
EXPECT_TRUE(send_array[i][j] == (*received_array)[i][j]);
EXPECT_EQ(send_array[i][j], (*received_array)[i][j]);
}
}
erpc_free(received_array);
Expand Down Expand Up @@ -185,7 +185,7 @@ TEST(test_arrays, sendReceivedList)
int32_t *list_r = (*received_array)[i].elements;
for (uint32_t j = 0; j < elements_count; ++j)
{
EXPECT_TRUE(*list_r == *list_s);
EXPECT_EQ(*list_r, *list_s);
list_r++;
list_s++;
}
Expand Down Expand Up @@ -224,7 +224,7 @@ TEST(test_arrays, sendReceived2List)
int32_t *list_r = (*received_array)[k][i].elements;
for (uint32_t j = 0; j < elements_count; ++j)
{
EXPECT_TRUE(*list_r == *list_s);
EXPECT_EQ(*list_r, *list_s);
list_r++;
list_s++;
}
Expand All @@ -250,7 +250,7 @@ TEST(test_arrays, sendReceivedInt32Type)

for (uint32_t i = 0; i < array_count; ++i)
{
EXPECT_TRUE(send_array[i] == (*received_array)[i]);
EXPECT_EQ(send_array[i], (*received_array)[i]);
}
erpc_free(received_array);
}
Expand All @@ -274,7 +274,7 @@ TEST(test_arrays, sendReceived2Int32Type)
{
for (uint32_t j = 0; j < 10; ++j)
{
EXPECT_TRUE(send_array[i][j] == (*received_array)[i][j]);
EXPECT_EQ(send_array[i][j], (*received_array)[i][j]);
}
}
erpc_free(received_array);
Expand Down Expand Up @@ -351,7 +351,7 @@ TEST(test_arrays, sendReceivedEnumType)

for (uint32_t i = 0; i < array_count; ++i)
{
EXPECT_TRUE(send_array[i] == (*received_array)[i]);
EXPECT_EQ(send_array[i], (*received_array)[i]);
}
erpc_free(received_array);
}
Expand All @@ -375,7 +375,7 @@ TEST(test_arrays, sendReceived2EnumType)
{
for (uint32_t j = 0; j < 3; ++j)
{
EXPECT_TRUE(send_array[i][j] == (*received_array)[i][j]);
EXPECT_EQ(send_array[i][j], (*received_array)[i][j]);
}
}
erpc_free(received_array);
Expand All @@ -397,8 +397,8 @@ TEST(test_arrays, sendReceivedStructType)

for (uint32_t i = 0; i < array_count; ++i)
{
EXPECT_TRUE(send_array[i].m == (*received_array)[i].m);
EXPECT_TRUE(send_array[i].n == (*received_array)[i].n);
EXPECT_EQ(send_array[i].m, (*received_array)[i].m);
EXPECT_EQ(send_array[i].n, (*received_array)[i].n);
}
erpc_free(received_array);
}
Expand All @@ -423,8 +423,8 @@ TEST(test_arrays, sendReceived2StructType)
{
for (uint32_t j = 0; j < 3; ++j)
{
EXPECT_TRUE(send_array[i][j].m == (*received_array)[i][j].m);
EXPECT_TRUE(send_array[i][j].n == (*received_array)[i][j].n);
EXPECT_EQ(send_array[i][j].m, (*received_array)[i][j].m);
EXPECT_EQ(send_array[i][j].n, (*received_array)[i][j].n);
}
}
erpc_free(received_array);
Expand Down Expand Up @@ -455,7 +455,7 @@ TEST(test_arrays, sendReceivedListType)
int32_t *list_r = (*received_array)[i].elements;
for (uint32_t j = 0; j < elements_count; ++j)
{
EXPECT_TRUE(*list_r == *list_s);
EXPECT_EQ(*list_r, *list_s);
list_r++;
list_s++;
}
Expand Down Expand Up @@ -494,7 +494,7 @@ TEST(test_arrays, sendReceived2ListType)
int32_t *list_r = (*received_array)[k][i].elements;
for (uint32_t j = 0; j < elements_count; ++j)
{
EXPECT_TRUE(*list_r == *list_s);
EXPECT_EQ(*list_r, *list_s);
list_r++;
list_s++;
}
Expand Down Expand Up @@ -545,18 +545,18 @@ TEST(test_arrays, sendReceiveStruct)

for (uint32_t k = 0; k < 2; ++k)
{
EXPECT_TRUE(send_struct[k].number == (*received_struct)[k].number);
EXPECT_EQ(send_struct[k].number, (*received_struct)[k].number);
EXPECT_STREQ(send_struct[k].text, (*received_struct)[k].text);
erpc_free(send_struct[k].text);
erpc_free((*received_struct)[k].text);
EXPECT_TRUE(send_struct[k].color == (*received_struct)[k].color);
EXPECT_TRUE(send_struct[k].c.m == (*received_struct)[k].c.m);
EXPECT_TRUE(send_struct[k].c.n == (*received_struct)[k].c.n);
EXPECT_EQ(send_struct[k].color, (*received_struct)[k].color);
EXPECT_EQ(send_struct[k].c.m, (*received_struct)[k].c.m);
EXPECT_EQ(send_struct[k].c.n, (*received_struct)[k].c.n);

EXPECT_TRUE(send_struct[k].list_numbers.elementsCount == (*received_struct)[k].list_numbers.elementsCount);
EXPECT_EQ(send_struct[k].list_numbers.elementsCount, (*received_struct)[k].list_numbers.elementsCount);
for (uint32_t i = 0; i < 5; ++i)
{
EXPECT_TRUE(send_struct[k].list_numbers.elements[i] == (*received_struct)[k].list_numbers.elements[i]);
EXPECT_EQ(send_struct[k].list_numbers.elements[i], (*received_struct)[k].list_numbers.elements[i]);
EXPECT_STREQ(send_struct[k].list_text.elements[i], (*received_struct)[k].list_text.elements[i]);
erpc_free(send_struct[k].list_text.elements[i]);
erpc_free((*received_struct)[k].list_text.elements[i]);
Expand All @@ -568,7 +568,7 @@ TEST(test_arrays, sendReceiveStruct)

for (uint32_t i = 0; i < 5; ++i)
{
EXPECT_TRUE(send_struct[k].array_numbers[i] == (*received_struct)[k].array_numbers[i]);
EXPECT_EQ(send_struct[k].array_numbers[i], (*received_struct)[k].array_numbers[i]);
EXPECT_STREQ(send_struct[k].array_text[i], (*received_struct)[k].array_text[i]);
erpc_free(send_struct[k].array_text[i]);
erpc_free((*received_struct)[k].array_text[i]);
Expand Down Expand Up @@ -622,20 +622,20 @@ TEST(test_arrays, sendReceive2Struct)
{
for (uint32_t l = 0; l < 1; ++l)
{
EXPECT_TRUE(send_struct[k][l].number == (*received_struct)[k][l].number);
EXPECT_EQ(send_struct[k][l].number, (*received_struct)[k][l].number);
EXPECT_STREQ(send_struct[k][l].text, (*received_struct)[k][l].text);
erpc_free(send_struct[k][l].text);
erpc_free((*received_struct)[k][l].text);
EXPECT_TRUE(send_struct[k][l].color == (*received_struct)[k][l].color);
EXPECT_TRUE(send_struct[k][l].c.m == (*received_struct)[k][l].c.m);
EXPECT_TRUE(send_struct[k][l].c.n == (*received_struct)[k][l].c.n);
EXPECT_EQ(send_struct[k][l].color, (*received_struct)[k][l].color);
EXPECT_EQ(send_struct[k][l].c.m, (*received_struct)[k][l].c.m);
EXPECT_EQ(send_struct[k][l].c.n, (*received_struct)[k][l].c.n);

EXPECT_TRUE(send_struct[k][l].list_numbers.elementsCount ==
(*received_struct)[k][l].list_numbers.elementsCount);
EXPECT_EQ(send_struct[k][l].list_numbers.elementsCount,
(*received_struct)[k][l].list_numbers.elementsCount);
for (uint32_t i = 0; i < 5; ++i)
{
EXPECT_TRUE(send_struct[k][l].list_numbers.elements[i] ==
(*received_struct)[k][l].list_numbers.elements[i]);
EXPECT_EQ(send_struct[k][l].list_numbers.elements[i],
(*received_struct)[k][l].list_numbers.elements[i]);
EXPECT_STREQ(send_struct[k][l].list_text.elements[i], (*received_struct)[k][l].list_text.elements[i]);
erpc_free(send_struct[k][l].list_text.elements[i]);
erpc_free((*received_struct)[k][l].list_text.elements[i]);
Expand All @@ -647,7 +647,7 @@ TEST(test_arrays, sendReceive2Struct)

for (uint32_t i = 0; i < 5; ++i)
{
EXPECT_TRUE(send_struct[k][l].array_numbers[i] == (*received_struct)[k][l].array_numbers[i]);
EXPECT_EQ(send_struct[k][l].array_numbers[i], (*received_struct)[k][l].array_numbers[i]);
EXPECT_STREQ(send_struct[k][l].array_text[i], (*received_struct)[k][l].array_text[i]);
erpc_free(send_struct[k][l].array_text[i]);
erpc_free((*received_struct)[k][l].array_text[i]);
Expand Down Expand Up @@ -683,9 +683,9 @@ TEST(test_arrays, test_array_allDirection)

for (uint32_t i = 0; i < 5; ++i)
{
EXPECT_TRUE(a[i] == pA[i]);
EXPECT_TRUE(b[i] == pB[i]);
EXPECT_TRUE(c[i] == pC[i]);
EXPECT_TRUE(d[i] == pD[i]);
EXPECT_EQ(a[i], pA[i]);
EXPECT_EQ(b[i], pB[i]);
EXPECT_EQ(c[i], pC[i]);
EXPECT_EQ(d[i], pD[i]);
}
}
12 changes: 6 additions & 6 deletions test/test_binary/test_binary_client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using namespace std;
result = sendReceiveBinary(&send);
for (uint8_t i = 0; i < result->dataLength; ++i)
{
EXPECT_TRUE(send.data[i] == result->data[i]);
EXPECT_EQ(send.data[i] , result->data[i]);
}
free(send.data);
free(result->data);
Expand All @@ -53,7 +53,7 @@ TEST(test_binary, sendBinary)
result = receiveBinary();
for (uint8_t i = 0; i < result->dataLength; ++i)
{
EXPECT_TRUE(i == result->data[i]);
EXPECT_EQ(i , result->data[i]);
}
free(result->data);
free(result);
Expand All @@ -80,7 +80,7 @@ TEST(test_binary, test_binary_allDirection)

for (uint8_t i = 0; i < 5; ++i)
{
EXPECT_TRUE(e.data[i] == a.data[i] * b.data[i]);
EXPECT_EQ(e.data[i], a.data[i] * b.data[i]);
}

erpc_free(a.data);
Expand Down Expand Up @@ -111,9 +111,9 @@ TEST(test_binary, test_binary_allDirection)
for (uint8_t i = 0; i < 5; ++i)
{
EXPECT_TRUE(a.data[i] == c.data[i]);
EXPECT_TRUE(b.data[i] == d->data[i]);
EXPECT_TRUE(e.data[i] == 4 * i);
EXPECT_EQ(a.data[i] , c.data[i]);
EXPECT_EQ(b.data[i] , d->data[i]);
EXPECT_EQ(e.data[i] , 4 * i);
}
free(a.data);
Expand Down
Loading

0 comments on commit 02541cd

Please sign in to comment.