summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/tests/libntp/numtohost.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ntp/tests/libntp/numtohost.c')
-rw-r--r--contrib/ntp/tests/libntp/numtohost.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/contrib/ntp/tests/libntp/numtohost.c b/contrib/ntp/tests/libntp/numtohost.c
new file mode 100644
index 0000000..7472f46
--- /dev/null
+++ b/contrib/ntp/tests/libntp/numtohost.c
@@ -0,0 +1,19 @@
+#include "config.h"
+
+#include "ntp_stdlib.h"
+#include "ntp_calendar.h"
+#include "ntp_fp.h"
+
+#include "unity.h"
+
+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
+ */
+
+ 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