Skip to content

Commit

Permalink
[tests] Fix -Wsign-compare
Browse files Browse the repository at this point in the history
  • Loading branch information
quink-black authored and maxsharabayko committed Jul 12, 2021
1 parent 94322d4 commit 3c1c490
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions test/test_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ TEST(CRcvBuffer, FullBuffer)
for (int i = 0; i < buffer_size_pkts - 1; ++i)
{
const int res = rcv_buffer.readBuffer(buff.data(), buff.size());
EXPECT_EQ(res, payload_size);
EXPECT_EQ(size_t(res), payload_size);
}
}

Expand Down Expand Up @@ -109,7 +109,7 @@ TEST(CRcvBuffer, ReadData)

std::array<char, payload_size> buff;
const int res = rcv_buffer.readBuffer(buff.data(), buff.size());
EXPECT_EQ(res, payload_size);
EXPECT_EQ(size_t(res), payload_size);
}


Expand Down Expand Up @@ -148,7 +148,7 @@ TEST(CRcvBuffer, AddData)
for (int i = 0; i < ack_pkts; ++i)
{
const int res = rcv_buffer.readBuffer(buff.data(), buff.size());
EXPECT_EQ(res, payload_size);
EXPECT_EQ(size_t(res), payload_size);
EXPECT_EQ(rcv_buffer.getAvailBufSize(), buffer_size_pkts - ack_pkts + i);
}

Expand Down
4 changes: 2 additions & 2 deletions test/test_epoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ TEST(CEPoll, HandleEpollEvent2)

int result = epoll.uwait(epoll_id, fds, 1024, -1);
ASSERT_EQ(result, 1);
ASSERT_EQ(fds[0].events, SRT_EPOLL_ERR);
ASSERT_EQ(fds[0].events, int(SRT_EPOLL_ERR));

// Edge-triggered means that after one wait call was done, the next
// call to this event should no longer report it. Now use timeout 0
Expand Down Expand Up @@ -529,7 +529,7 @@ TEST(CEPoll, ThreadedUpdate)
int result = epoll.uwait(epoll_id, fds, 1024, -1);
cerr << "Exit no longer infinite-wait by uwait, result=" << result << "\n";
ASSERT_EQ(result, 1);
ASSERT_EQ(fds[0].events, SRT_EPOLL_ERR);
ASSERT_EQ(fds[0].events, int(SRT_EPOLL_ERR));

cerr << "THREAD JOIN...\n";
td.join();
Expand Down
6 changes: 3 additions & 3 deletions test/test_fec_rebuilding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ TEST_F(TestFECRebuilding, NoRebuild)

bool want_passthru_fec = fec->receive(*fecpkt, loss);
EXPECT_EQ(want_passthru_fec, false); // Confirm that it's been eaten up
EXPECT_EQ(provided.size(), 0); // Confirm that nothing was rebuilt
EXPECT_EQ(provided.size(), 0U); // Confirm that nothing was rebuilt

/*
// XXX With such a short sequence, losses will not be reported.
Expand Down Expand Up @@ -879,8 +879,8 @@ TEST_F(TestFECRebuilding, Rebuild)
const bool want_passthru_fec = fec->receive(*fecpkt, loss);
EXPECT_EQ(want_passthru_fec, false); // Confirm that it's been eaten up

EXPECT_EQ(loss.size(), 0);
ASSERT_EQ(provided.size(), 1);
EXPECT_EQ(loss.size(), 0U);
ASSERT_EQ(provided.size(), 1U);

SrtPacket& rebuilt = provided[0];
CPacket& skipped = *source[4];
Expand Down
2 changes: 1 addition & 1 deletion test/test_ipv6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class TestIPv6

void ShowAddress(std::string src, const sockaddr_any& w)
{
ASSERT_NE(fam.count(w.family()), 0) << "INVALID FAMILY";
ASSERT_NE(fam.count(w.family()), 0U) << "INVALID FAMILY";
std::cout << src << ": " << w.str() << " (" << fam[w.family()] << ")" << std::endl;
}

Expand Down
2 changes: 1 addition & 1 deletion test/test_seqno.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TEST(CSeqNo, seqcmp)
EXPECT_EQ(CSeqNo::seqcmp(1, 128), -127);

// abs(seq1 - seq2) >= 0x3FFFFFFF : seq2 - seq1
EXPECT_EQ(CSeqNo::seqcmp(0x7FFFFFFF, 1), 0x80000002); // -2147483646
EXPECT_EQ(CSeqNo::seqcmp(0x7FFFFFFF, 1), int(0x80000002)); // -2147483646
EXPECT_EQ(CSeqNo::seqcmp(1, 0x7FFFFFFF), 0x7FFFFFFE); // 2147483646
}

Expand Down
20 changes: 10 additions & 10 deletions test/test_socket_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ TEST_F(TestSocketOptions, LossMaxTTL)
int opt_len = 0;
ASSERT_EQ(srt_getsockopt(accepted_sock, 0, SRTO_LOSSMAXTTL, &opt_val, &opt_len), SRT_SUCCESS);
EXPECT_EQ(opt_val, loss_max_ttl) << "Wrong SRTO_LOSSMAXTTL value on the accepted socket";
EXPECT_EQ(opt_len, sizeof opt_len) << "Wrong SRTO_LOSSMAXTTL value length on the accepted socket";
EXPECT_EQ(size_t(opt_len), sizeof opt_len) << "Wrong SRTO_LOSSMAXTTL value length on the accepted socket";

SRT_TRACEBSTATS stats;
EXPECT_EQ(srt_bstats(accepted_sock, &stats, 0), SRT_SUCCESS);
EXPECT_EQ(stats.pktReorderTolerance, loss_max_ttl);

ASSERT_EQ(srt_getsockopt(m_listen_sock, 0, SRTO_LOSSMAXTTL, &opt_val, &opt_len), SRT_SUCCESS);
EXPECT_EQ(opt_val, loss_max_ttl) << "Wrong SRTO_LOSSMAXTTL value on the listener socket";
EXPECT_EQ(opt_len, sizeof opt_len) << "Wrong SRTO_LOSSMAXTTL value length on the listener socket";
EXPECT_EQ(size_t(opt_len), sizeof opt_len) << "Wrong SRTO_LOSSMAXTTL value length on the listener socket";

ASSERT_NE(srt_close(accepted_sock), SRT_ERROR);
}
Expand Down Expand Up @@ -272,7 +272,7 @@ TEST_F(TestSocketOptions, StreamIDOdd)
int buffer_len = sizeof buffer;
EXPECT_EQ(srt_getsockopt(m_caller_sock, 0, SRTO_STREAMID, &buffer, &buffer_len), SRT_SUCCESS);
EXPECT_EQ(std::string(buffer), sid_odd);
EXPECT_EQ(buffer_len, sid_odd.size());
EXPECT_EQ(size_t(buffer_len), sid_odd.size());
EXPECT_EQ(strlen(buffer), sid_odd.size());

StartListener();
Expand All @@ -283,7 +283,7 @@ TEST_F(TestSocketOptions, StreamIDOdd)
buffer[i] = 'a';
buffer_len = (int)(sizeof buffer);
EXPECT_EQ(srt_getsockopt(accepted_sock, 0, SRTO_STREAMID, &buffer, &buffer_len), SRT_SUCCESS);
EXPECT_EQ(buffer_len, sid_odd.size());
EXPECT_EQ(size_t(buffer_len), sid_odd.size());
EXPECT_EQ(strlen(buffer), sid_odd.size());

ASSERT_NE(srt_close(accepted_sock), SRT_ERROR);
Expand All @@ -301,7 +301,7 @@ TEST_F(TestSocketOptions, StreamIDEven)
int buffer_len = sizeof buffer;
EXPECT_EQ(srt_getsockopt(m_caller_sock, 0, SRTO_STREAMID, &buffer, &buffer_len), SRT_SUCCESS);
EXPECT_EQ(std::string(buffer), sid_even);
EXPECT_EQ(buffer_len, sid_even.size());
EXPECT_EQ(size_t(buffer_len), sid_even.size());
EXPECT_EQ(strlen(buffer), sid_even.size());

StartListener();
Expand All @@ -312,7 +312,7 @@ TEST_F(TestSocketOptions, StreamIDEven)
buffer[i] = 'a';
buffer_len = (int)(sizeof buffer);
EXPECT_EQ(srt_getsockopt(accepted_sock, 0, SRTO_STREAMID, &buffer, &buffer_len), SRT_SUCCESS);
EXPECT_EQ(buffer_len, sid_even.size());
EXPECT_EQ(size_t(buffer_len), sid_even.size());
EXPECT_EQ(strlen(buffer), sid_even.size());

ASSERT_NE(srt_close(accepted_sock), SRT_ERROR);
Expand All @@ -337,7 +337,7 @@ TEST_F(TestSocketOptions, StreamIDAlmostFull)
int buffer_len = sizeof buffer;
EXPECT_EQ(srt_getsockopt(m_caller_sock, 0, SRTO_STREAMID, &buffer, &buffer_len), SRT_SUCCESS);
EXPECT_EQ(std::string(buffer), sid_amost_full);
EXPECT_EQ(buffer_len, sid_amost_full.size());
EXPECT_EQ(size_t(buffer_len), sid_amost_full.size());
EXPECT_EQ(strlen(buffer), sid_amost_full.size());

StartListener();
Expand All @@ -348,7 +348,7 @@ TEST_F(TestSocketOptions, StreamIDAlmostFull)
buffer[i] = 'a';
buffer_len = (int)(sizeof buffer);
EXPECT_EQ(srt_getsockopt(accepted_sock, 0, SRTO_STREAMID, &buffer, &buffer_len), SRT_SUCCESS);
EXPECT_EQ(buffer_len, sid_amost_full.size());
EXPECT_EQ(size_t(buffer_len), sid_amost_full.size());
EXPECT_EQ(strlen(buffer), sid_amost_full.size());
EXPECT_EQ(buffer[sid_amost_full.size()-1], 'z');

Expand All @@ -373,7 +373,7 @@ TEST_F(TestSocketOptions, StreamIDFull)
int buffer_len = sizeof buffer;
EXPECT_EQ(srt_getsockopt(m_caller_sock, 0, SRTO_STREAMID, &buffer, &buffer_len), SRT_SUCCESS);
EXPECT_EQ(std::string(buffer), sid_full);
EXPECT_EQ(buffer_len, sid_full.size());
EXPECT_EQ(size_t(buffer_len), sid_full.size());
EXPECT_EQ(strlen(buffer), sid_full.size());

StartListener();
Expand All @@ -384,7 +384,7 @@ TEST_F(TestSocketOptions, StreamIDFull)
buffer[i] = 'a';
buffer_len = (int)(sizeof buffer);
EXPECT_EQ(srt_getsockopt(accepted_sock, 0, SRTO_STREAMID, &buffer, &buffer_len), SRT_SUCCESS);
EXPECT_EQ(buffer_len, sid_full.size());
EXPECT_EQ(size_t(buffer_len), sid_full.size());
EXPECT_EQ(strlen(buffer), sid_full.size());
EXPECT_EQ(buffer[sid_full.size()-1], 'z');

Expand Down
6 changes: 3 additions & 3 deletions test/test_sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ TEST(SyncEvent, WaitForTwoNotifyOne)

// Now exactly one waiting thread should become ready
// Error if: 0 (none ready) or 2 (both ready, while notify_one was used)
ASSERT_EQ(notified_clients.size(), 1);
ASSERT_EQ(notified_clients.size(), 1U);

const int ready = notified_clients[0];
const int not_ready = (ready + 1) % 2;
Expand Down Expand Up @@ -611,7 +611,7 @@ TEST(Sync, FormatTime)
const regex rex("([[:digit:]]+D )?([[:digit:]]{2}):([[:digit:]]{2}):([[:digit:]]{2}).([[:digit:]]{6,}) \\[STDY\\]");
std::smatch sm;
EXPECT_TRUE(regex_match(timestr, sm, rex));
EXPECT_LE(sm.size(), 6);
EXPECT_LE(sm.size(), 6U);
if (sm.size() != 6 && sm.size() != 5)
return 0;

Expand Down Expand Up @@ -655,7 +655,7 @@ TEST(Sync, FormatTimeSys)
const regex rex("([[:digit:]]{2}):([[:digit:]]{2}):([[:digit:]]{2}).([[:digit:]]{6}) \\[SYST\\]");
std::smatch sm;
EXPECT_TRUE(regex_match(timestr, sm, rex));
EXPECT_EQ(sm.size(), 5);
EXPECT_EQ(sm.size(), 5U);
if (sm.size() != 5)
return 0;

Expand Down
6 changes: 3 additions & 3 deletions test/test_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ TEST(ConfigString, Setting)
StringStorage<STRSIZE> s;

EXPECT_TRUE(s.empty());
EXPECT_EQ(s.size(), 0);
EXPECT_EQ(s.size(), 0U);
EXPECT_EQ(s.str(), std::string());

char example_ac1[] = "example_long";
Expand All @@ -246,7 +246,7 @@ TEST(ConfigString, Setting)
EXPECT_EQ(s.size(), sizeof (example_ac3)-1);

EXPECT_TRUE(s.set(example_ace, sizeof (example_ace)-1));
EXPECT_EQ(s.size(), 0);
EXPECT_EQ(s.size(), 0U);

string example_s1 = "example_long";
string example_s2 = "short";
Expand All @@ -268,6 +268,6 @@ TEST(ConfigString, Setting)
EXPECT_EQ(s.size(), example_s3.size());

EXPECT_TRUE(s.set(example_se));
EXPECT_EQ(s.size(), 0);
EXPECT_EQ(s.size(), 0U);
EXPECT_TRUE(s.empty());
}

0 comments on commit 3c1c490

Please sign in to comment.