]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/ntp/tests/libntp/numtoa.c
Upgrade NTP to 4.2.8p4.
[FreeBSD/releng/10.2.git] / contrib / ntp / tests / libntp / numtoa.c
1 #include "config.h"
2
3 #include "ntp_stdlib.h"
4 #include "ntp_fp.h"
5
6 #include "unity.h"
7
8 void test_Address(void);
9 void test_Netmask(void);
10
11 void
12 test_Address(void) {
13         const u_int32 input = htonl(3221225472UL + 512UL + 1UL); // 192.0.2.1
14
15         TEST_ASSERT_EQUAL_STRING("192.0.2.1", numtoa(input));
16 }
17
18 void
19 test_Netmask(void) {
20         // 255.255.255.0
21         const u_int32 hostOrder = 255UL*256UL*256UL*256UL + 255UL*256UL*256UL + 255UL*256UL;
22         const u_int32 input = htonl(hostOrder);
23
24         TEST_ASSERT_EQUAL_STRING("255.255.255.0", numtoa(input));
25 }