1 #include "g_libntptest.h"
4 #include "ntp_refclock.h"
8 class refnumtoaTest : public libntptest {
10 /* Might need to be updated if a new refclock gets this id. */
11 static const int UNUSED_REFCLOCK_ID = 250;
14 #ifdef REFCLOCK /* clockname() is useless otherwise */
15 TEST_F(refnumtoaTest, LocalClock) {
16 /* We test with a refclock address of type LOCALCLOCK.
19 u_int32 addr = REFCLOCK_ADDR;
20 addr |= REFCLK_LOCALCLOCK << 8;
24 address.sa4.sin_family = AF_INET;
25 address.sa4.sin_addr.s_addr = htonl(addr);
27 std::ostringstream expected;
28 expected << clockname(REFCLK_LOCALCLOCK)
31 EXPECT_STREQ(expected.str().c_str(), refnumtoa(&address));
35 #ifdef REFCLOCK /* refnumtoa() is useless otherwise */
36 TEST_F(refnumtoaTest, UnknownId) {
37 /* We test with a currently unused refclock ID */
38 u_int32 addr = REFCLOCK_ADDR;
39 addr |= UNUSED_REFCLOCK_ID << 8;
43 address.sa4.sin_family = AF_INET;
44 address.sa4.sin_addr.s_addr = htonl(addr);
46 std::ostringstream expected;
47 expected << "REFCLK(" << UNUSED_REFCLOCK_ID
50 EXPECT_STREQ(expected.str().c_str(), refnumtoa(&address));