summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/tests/libntp/numtoa.c
blob: 5c7a663f4a21e51add027a4eedb6d8a1fc326046 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "config.h"

#include "ntp_stdlib.h"
#include "ntp_fp.h"

#include "unity.h"

void test_Address(void);
void test_Netmask(void);

void
test_Address(void) {
	const u_int32 input = htonl(3221225472UL + 512UL + 1UL); // 192.0.2.1

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

void
test_Netmask(void) {
	// 255.255.255.0
	const u_int32 hostOrder = 255UL*256UL*256UL*256UL + 255UL*256UL*256UL + 255UL*256UL;
	const u_int32 input = htonl(hostOrder);

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