summaryrefslogtreecommitdiff
path: root/tests/libntp/numtoa.cpp
blob: 58e00c4c27ec656e7d393212af46af26694081bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "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));
}