supercell-wx/test/source/scwx/network/ntp_client.test.cpp
2025-08-24 22:28:38 -05:00

32 lines
748 B
C++

#include <scwx/network/ntp_client.hpp>
#include <gtest/gtest.h>
namespace scwx::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 scwx::network