summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/tests/libntp/g_numtoa.cpp
blob: a68e80dbd65d44a3b75b032c0371b896e910ae33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "g_libntptest.h"

class numtoaTest : public libntptest {
};

TEST_F(numtoaTest, Address) {
	u_int32 input = htonl(3221225472UL+512UL+1UL); // 192.0.2.1

	EXPECT_STREQ("192.0.2.1", numtoa(input));
}

TEST_F(numtoaTest, Netmask) {
	// 255.255.255.0
	u_int32 hostOrder = 255UL*256UL*256UL*256UL + 255UL*256UL*256UL + 255UL*256UL;
	u_int32 input = htonl(hostOrder);

	EXPECT_STREQ("255.255.255.0", numtoa(input));
}
OpenPOWER on IntegriCloud