Skip to content

Commit 02541cd

Browse files
authored
Replace EXPECT_TRUE with EXPECT_EQ (#318)
EXPECT_EQ provide more information in most of cases on fail. Signed-off-by: Cervenka Dusan <[email protected]> Signed-off-by: Cervenka Dusan <[email protected]>
1 parent c313d54 commit 02541cd

File tree

14 files changed

+159
-159
lines changed

14 files changed

+159
-159
lines changed

test/common/gtestListener.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class LeakChecker : public ::testing::EmptyTestEventListener
2626
{
2727
int serverAlloc = getServerAllocated();
2828

29-
EXPECT_TRUE(MyAlloc::allocated() == 0)
29+
EXPECT_EQ(MyAlloc::allocated(), 0)
3030
<< "Leaked (on client side) : " << MyAlloc::allocated() << " unit(s) need be freed!";
31-
EXPECT_TRUE(serverAlloc == 0) << "Leaked (on server side) : " << serverAlloc << " unit(s) need be freed!";
31+
EXPECT_EQ(serverAlloc, 0) << "Leaked (on server side) : " << serverAlloc << " unit(s) need be freed!";
3232
MyAlloc::allocated(0);
3333
}
3434
};

test/test_annotations/test_annotations_client_impl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515

1616
TEST(test_annotations, AnnotationServiceID)
1717
{
18-
EXPECT_TRUE(5 == kAnnotateTest_service_id);
18+
EXPECT_EQ(kAnnotateTest_service_id, 5);
1919
}
2020

2121
TEST(test_annotations, IncludeAnnotationCheck)
2222
{
23-
EXPECT_TRUE(5 == addOne(4));
23+
EXPECT_EQ(addOne(4), 5);
2424

2525
includedInt_t testInt = 5;
26-
EXPECT_TRUE(5 == testInt);
26+
EXPECT_EQ(testInt, 5);
2727
}
2828

2929
TEST(test_annotations, testIfMyIntAndConstExist)
3030
{
31-
EXPECT_TRUE(i == testIfMyIntAndConstExist(i));
31+
EXPECT_EQ(i, testIfMyIntAndConstExist(i));
3232
}

test/test_arbitrator/test_arbitrator_client_impl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ TEST(test_arbitrator, FirstSendReceiveInt)
3232
for (int i = number - 1; i >= 0; i--)
3333
{
3434
int b = firstReceiveInt();
35-
EXPECT_TRUE(i == b);
35+
EXPECT_EQ(i, b);
3636
}
3737
}
3838

@@ -45,7 +45,7 @@ TEST(test_arbitrator, FirstSendReceiveInt2)
4545
for (int i = number - 1; i >= 0; i--)
4646
{
4747
int b = firstReceiveInt();
48-
EXPECT_TRUE(i == b);
48+
EXPECT_EQ(i, b);
4949
}
5050
}
5151

@@ -55,12 +55,12 @@ TEST(test_arbitrator, NestedCallTest)
5555
while (!enabled)
5656
{
5757
};
58-
EXPECT_TRUE(nestedCallTest() == nestedCallsCount * 2 - 1);
58+
EXPECT_EQ(nestedCallTest(), nestedCallsCount * 2 - 1);
5959
}
6060

6161
TEST(test_arbitrator, GetResultFromSecondSide)
6262
{
63-
EXPECT_TRUE(getResultFromSecondSide() == 0);
63+
EXPECT_EQ(getResultFromSecondSide(), 0);
6464
}
6565

6666
TEST(test_arbitrator, testCasesAreDone)

test/test_arrays/test_arrays_client_impl.cpp

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ TEST(test_arrays, sendReceivedInt32)
3030

3131
for (uint32_t i = 0; i < array_count; ++i)
3232
{
33-
EXPECT_TRUE(send_array[i] == (*received_array)[i]);
33+
EXPECT_EQ(send_array[i], (*received_array)[i]);
3434
}
3535
erpc_free(received_array);
3636
}
@@ -53,7 +53,7 @@ TEST(test_arrays, sendReceived2Int32)
5353
{
5454
for (uint32_t j = 0; j < 10; ++j)
5555
{
56-
EXPECT_TRUE(send_array[i][j] == (*received_array)[i][j]);
56+
EXPECT_EQ(send_array[i][j], (*received_array)[i][j]);
5757
}
5858
}
5959
erpc_free(received_array);
@@ -130,7 +130,7 @@ TEST(test_arrays, sendReceivedEnum)
130130

131131
for (uint32_t i = 0; i < array_count; ++i)
132132
{
133-
EXPECT_TRUE(send_array[i] == (*received_array)[i]);
133+
EXPECT_EQ(send_array[i], (*received_array)[i]);
134134
}
135135
erpc_free(received_array);
136136
}
@@ -154,7 +154,7 @@ TEST(test_arrays, sendReceived2Enum)
154154
{
155155
for (uint32_t j = 0; j < 3; ++j)
156156
{
157-
EXPECT_TRUE(send_array[i][j] == (*received_array)[i][j]);
157+
EXPECT_EQ(send_array[i][j], (*received_array)[i][j]);
158158
}
159159
}
160160
erpc_free(received_array);
@@ -185,7 +185,7 @@ TEST(test_arrays, sendReceivedList)
185185
int32_t *list_r = (*received_array)[i].elements;
186186
for (uint32_t j = 0; j < elements_count; ++j)
187187
{
188-
EXPECT_TRUE(*list_r == *list_s);
188+
EXPECT_EQ(*list_r, *list_s);
189189
list_r++;
190190
list_s++;
191191
}
@@ -224,7 +224,7 @@ TEST(test_arrays, sendReceived2List)
224224
int32_t *list_r = (*received_array)[k][i].elements;
225225
for (uint32_t j = 0; j < elements_count; ++j)
226226
{
227-
EXPECT_TRUE(*list_r == *list_s);
227+
EXPECT_EQ(*list_r, *list_s);
228228
list_r++;
229229
list_s++;
230230
}
@@ -250,7 +250,7 @@ TEST(test_arrays, sendReceivedInt32Type)
250250

251251
for (uint32_t i = 0; i < array_count; ++i)
252252
{
253-
EXPECT_TRUE(send_array[i] == (*received_array)[i]);
253+
EXPECT_EQ(send_array[i], (*received_array)[i]);
254254
}
255255
erpc_free(received_array);
256256
}
@@ -274,7 +274,7 @@ TEST(test_arrays, sendReceived2Int32Type)
274274
{
275275
for (uint32_t j = 0; j < 10; ++j)
276276
{
277-
EXPECT_TRUE(send_array[i][j] == (*received_array)[i][j]);
277+
EXPECT_EQ(send_array[i][j], (*received_array)[i][j]);
278278
}
279279
}
280280
erpc_free(received_array);
@@ -351,7 +351,7 @@ TEST(test_arrays, sendReceivedEnumType)
351351

352352
for (uint32_t i = 0; i < array_count; ++i)
353353
{
354-
EXPECT_TRUE(send_array[i] == (*received_array)[i]);
354+
EXPECT_EQ(send_array[i], (*received_array)[i]);
355355
}
356356
erpc_free(received_array);
357357
}
@@ -375,7 +375,7 @@ TEST(test_arrays, sendReceived2EnumType)
375375
{
376376
for (uint32_t j = 0; j < 3; ++j)
377377
{
378-
EXPECT_TRUE(send_array[i][j] == (*received_array)[i][j]);
378+
EXPECT_EQ(send_array[i][j], (*received_array)[i][j]);
379379
}
380380
}
381381
erpc_free(received_array);
@@ -397,8 +397,8 @@ TEST(test_arrays, sendReceivedStructType)
397397

398398
for (uint32_t i = 0; i < array_count; ++i)
399399
{
400-
EXPECT_TRUE(send_array[i].m == (*received_array)[i].m);
401-
EXPECT_TRUE(send_array[i].n == (*received_array)[i].n);
400+
EXPECT_EQ(send_array[i].m, (*received_array)[i].m);
401+
EXPECT_EQ(send_array[i].n, (*received_array)[i].n);
402402
}
403403
erpc_free(received_array);
404404
}
@@ -423,8 +423,8 @@ TEST(test_arrays, sendReceived2StructType)
423423
{
424424
for (uint32_t j = 0; j < 3; ++j)
425425
{
426-
EXPECT_TRUE(send_array[i][j].m == (*received_array)[i][j].m);
427-
EXPECT_TRUE(send_array[i][j].n == (*received_array)[i][j].n);
426+
EXPECT_EQ(send_array[i][j].m, (*received_array)[i][j].m);
427+
EXPECT_EQ(send_array[i][j].n, (*received_array)[i][j].n);
428428
}
429429
}
430430
erpc_free(received_array);
@@ -455,7 +455,7 @@ TEST(test_arrays, sendReceivedListType)
455455
int32_t *list_r = (*received_array)[i].elements;
456456
for (uint32_t j = 0; j < elements_count; ++j)
457457
{
458-
EXPECT_TRUE(*list_r == *list_s);
458+
EXPECT_EQ(*list_r, *list_s);
459459
list_r++;
460460
list_s++;
461461
}
@@ -494,7 +494,7 @@ TEST(test_arrays, sendReceived2ListType)
494494
int32_t *list_r = (*received_array)[k][i].elements;
495495
for (uint32_t j = 0; j < elements_count; ++j)
496496
{
497-
EXPECT_TRUE(*list_r == *list_s);
497+
EXPECT_EQ(*list_r, *list_s);
498498
list_r++;
499499
list_s++;
500500
}
@@ -545,18 +545,18 @@ TEST(test_arrays, sendReceiveStruct)
545545

546546
for (uint32_t k = 0; k < 2; ++k)
547547
{
548-
EXPECT_TRUE(send_struct[k].number == (*received_struct)[k].number);
548+
EXPECT_EQ(send_struct[k].number, (*received_struct)[k].number);
549549
EXPECT_STREQ(send_struct[k].text, (*received_struct)[k].text);
550550
erpc_free(send_struct[k].text);
551551
erpc_free((*received_struct)[k].text);
552-
EXPECT_TRUE(send_struct[k].color == (*received_struct)[k].color);
553-
EXPECT_TRUE(send_struct[k].c.m == (*received_struct)[k].c.m);
554-
EXPECT_TRUE(send_struct[k].c.n == (*received_struct)[k].c.n);
552+
EXPECT_EQ(send_struct[k].color, (*received_struct)[k].color);
553+
EXPECT_EQ(send_struct[k].c.m, (*received_struct)[k].c.m);
554+
EXPECT_EQ(send_struct[k].c.n, (*received_struct)[k].c.n);
555555

556-
EXPECT_TRUE(send_struct[k].list_numbers.elementsCount == (*received_struct)[k].list_numbers.elementsCount);
556+
EXPECT_EQ(send_struct[k].list_numbers.elementsCount, (*received_struct)[k].list_numbers.elementsCount);
557557
for (uint32_t i = 0; i < 5; ++i)
558558
{
559-
EXPECT_TRUE(send_struct[k].list_numbers.elements[i] == (*received_struct)[k].list_numbers.elements[i]);
559+
EXPECT_EQ(send_struct[k].list_numbers.elements[i], (*received_struct)[k].list_numbers.elements[i]);
560560
EXPECT_STREQ(send_struct[k].list_text.elements[i], (*received_struct)[k].list_text.elements[i]);
561561
erpc_free(send_struct[k].list_text.elements[i]);
562562
erpc_free((*received_struct)[k].list_text.elements[i]);
@@ -568,7 +568,7 @@ TEST(test_arrays, sendReceiveStruct)
568568

569569
for (uint32_t i = 0; i < 5; ++i)
570570
{
571-
EXPECT_TRUE(send_struct[k].array_numbers[i] == (*received_struct)[k].array_numbers[i]);
571+
EXPECT_EQ(send_struct[k].array_numbers[i], (*received_struct)[k].array_numbers[i]);
572572
EXPECT_STREQ(send_struct[k].array_text[i], (*received_struct)[k].array_text[i]);
573573
erpc_free(send_struct[k].array_text[i]);
574574
erpc_free((*received_struct)[k].array_text[i]);
@@ -622,20 +622,20 @@ TEST(test_arrays, sendReceive2Struct)
622622
{
623623
for (uint32_t l = 0; l < 1; ++l)
624624
{
625-
EXPECT_TRUE(send_struct[k][l].number == (*received_struct)[k][l].number);
625+
EXPECT_EQ(send_struct[k][l].number, (*received_struct)[k][l].number);
626626
EXPECT_STREQ(send_struct[k][l].text, (*received_struct)[k][l].text);
627627
erpc_free(send_struct[k][l].text);
628628
erpc_free((*received_struct)[k][l].text);
629-
EXPECT_TRUE(send_struct[k][l].color == (*received_struct)[k][l].color);
630-
EXPECT_TRUE(send_struct[k][l].c.m == (*received_struct)[k][l].c.m);
631-
EXPECT_TRUE(send_struct[k][l].c.n == (*received_struct)[k][l].c.n);
629+
EXPECT_EQ(send_struct[k][l].color, (*received_struct)[k][l].color);
630+
EXPECT_EQ(send_struct[k][l].c.m, (*received_struct)[k][l].c.m);
631+
EXPECT_EQ(send_struct[k][l].c.n, (*received_struct)[k][l].c.n);
632632

633-
EXPECT_TRUE(send_struct[k][l].list_numbers.elementsCount ==
634-
(*received_struct)[k][l].list_numbers.elementsCount);
633+
EXPECT_EQ(send_struct[k][l].list_numbers.elementsCount,
634+
(*received_struct)[k][l].list_numbers.elementsCount);
635635
for (uint32_t i = 0; i < 5; ++i)
636636
{
637-
EXPECT_TRUE(send_struct[k][l].list_numbers.elements[i] ==
638-
(*received_struct)[k][l].list_numbers.elements[i]);
637+
EXPECT_EQ(send_struct[k][l].list_numbers.elements[i],
638+
(*received_struct)[k][l].list_numbers.elements[i]);
639639
EXPECT_STREQ(send_struct[k][l].list_text.elements[i], (*received_struct)[k][l].list_text.elements[i]);
640640
erpc_free(send_struct[k][l].list_text.elements[i]);
641641
erpc_free((*received_struct)[k][l].list_text.elements[i]);
@@ -647,7 +647,7 @@ TEST(test_arrays, sendReceive2Struct)
647647

648648
for (uint32_t i = 0; i < 5; ++i)
649649
{
650-
EXPECT_TRUE(send_struct[k][l].array_numbers[i] == (*received_struct)[k][l].array_numbers[i]);
650+
EXPECT_EQ(send_struct[k][l].array_numbers[i], (*received_struct)[k][l].array_numbers[i]);
651651
EXPECT_STREQ(send_struct[k][l].array_text[i], (*received_struct)[k][l].array_text[i]);
652652
erpc_free(send_struct[k][l].array_text[i]);
653653
erpc_free((*received_struct)[k][l].array_text[i]);
@@ -683,9 +683,9 @@ TEST(test_arrays, test_array_allDirection)
683683

684684
for (uint32_t i = 0; i < 5; ++i)
685685
{
686-
EXPECT_TRUE(a[i] == pA[i]);
687-
EXPECT_TRUE(b[i] == pB[i]);
688-
EXPECT_TRUE(c[i] == pC[i]);
689-
EXPECT_TRUE(d[i] == pD[i]);
686+
EXPECT_EQ(a[i], pA[i]);
687+
EXPECT_EQ(b[i], pB[i]);
688+
EXPECT_EQ(c[i], pC[i]);
689+
EXPECT_EQ(d[i], pD[i]);
690690
}
691691
}

test/test_binary/test_binary_client_impl.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ using namespace std;
2727
result = sendReceiveBinary(&send);
2828
for (uint8_t i = 0; i < result->dataLength; ++i)
2929
{
30-
EXPECT_TRUE(send.data[i] == result->data[i]);
30+
EXPECT_EQ(send.data[i] , result->data[i]);
3131
}
3232
free(send.data);
3333
free(result->data);
@@ -53,7 +53,7 @@ TEST(test_binary, sendBinary)
5353
result = receiveBinary();
5454
for (uint8_t i = 0; i < result->dataLength; ++i)
5555
{
56-
EXPECT_TRUE(i == result->data[i]);
56+
EXPECT_EQ(i , result->data[i]);
5757
}
5858
free(result->data);
5959
free(result);
@@ -80,7 +80,7 @@ TEST(test_binary, test_binary_allDirection)
8080

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

8686
erpc_free(a.data);
@@ -111,9 +111,9 @@ TEST(test_binary, test_binary_allDirection)
111111
112112
for (uint8_t i = 0; i < 5; ++i)
113113
{
114-
EXPECT_TRUE(a.data[i] == c.data[i]);
115-
EXPECT_TRUE(b.data[i] == d->data[i]);
116-
EXPECT_TRUE(e.data[i] == 4 * i);
114+
EXPECT_EQ(a.data[i] , c.data[i]);
115+
EXPECT_EQ(b.data[i] , d->data[i]);
116+
EXPECT_EQ(e.data[i] , 4 * i);
117117
}
118118
119119
free(a.data);

0 commit comments

Comments
 (0)