supercell-wx/test/source/scwx/network/ntp_client.test.cpp
2025-08-10 18:03:32 -05:00

35 lines
773 B
C++

#include <scwx/network/ntp_client.hpp>
#include <gtest/gtest.h>
namespace scwx
{
namespace network
{
TEST(NtpClient, Poll)
{
NtpClient client {};
const std::string firstServer = client.RotateServer();
std::string currentServer = firstServer;
std::string lastServer = firstServer;
bool error = false;
do
{
client.RunOnce();
error = client.error();
EXPECT_EQ(error, false);
// Loop until the current server repeats the first server, or fails to
// rotate
lastServer = currentServer;
currentServer = client.RotateServer();
} while (currentServer != firstServer && currentServer != lastServer &&
!error);
}
} // namespace network
} // namespace scwx