summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/tests/libntp/numtohost.c
blob: 1c095eb55cdd8aaa76f34a2eb32c3bfaf2e18cf5 (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
26
27
28
29
30
31
#include "config.h"

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

#include "unity.h"

void setUp(void);
void test_LoopbackNetNonResolve(void);


void
setUp(void)
{
	init_lib();

	return;
}


void
test_LoopbackNetNonResolve(void) {
	/* A loopback address in 127.0.0.0/8 is chosen, and
	 * numtohost() should not try to resolve it unless
	 * it is 127.0.0.1
	 */

	const u_int32 input = 127*256*256*256 + 1*256 + 1; // 127.0.1.1

	TEST_ASSERT_EQUAL_STRING("127.0.1.1", numtohost(htonl(input)));
}
OpenPOWER on IntegriCloud