fixed failed tests

This commit is contained in:
Erik Frojdh 2020-02-25 09:26:57 +01:00
parent f902bb06ad
commit 2bec476b4f
2 changed files with 5 additions and 10 deletions

View File

@ -90,18 +90,13 @@ class UdpRxSocket {
} }
const char *LastPacket() const noexcept { return buff; } const char *LastPacket() const noexcept { return buff; }
//constexpr
ssize_t getPacketSize() const noexcept { return packet_size; } ssize_t getPacketSize() const noexcept { return packet_size; }
bool ReceivePacket() noexcept { bool ReceivePacket() noexcept { return ReceivePacket(buff); }
auto bytes_received =
recvfrom(fd, buff, packet_size, 0, nullptr, nullptr);
return bytes_received == packet_size;
}
bool ReceivePacket(char *dst) noexcept { bool ReceivePacket(char *dst) noexcept {
auto bytes_received = auto bytes_received =
recvfrom(fd, buff, packet_size, 0, nullptr, nullptr); recvfrom(fd, dst, packet_size, 0, nullptr, nullptr);
return bytes_received == packet_size; return bytes_received == packet_size;
} }

View File

@ -70,7 +70,7 @@ TEST_CASE("Shutdown socket without hanging when waiting for data") {
&sls::UdpRxSocket::ReceivePacket), &sls::UdpRxSocket::ReceivePacket),
&s); &s);
s.Close(); s.Shutdown();
auto r = ret.get(); auto r = ret.get();
CHECK(r == false); // since we didn't get the packet CHECK(r == false); // since we didn't get the packet