aboutsummaryrefslogtreecommitdiff
path: root/tests/libntp/numtoa.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/libntp/numtoa.c')
-rw-r--r--tests/libntp/numtoa.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/libntp/numtoa.c b/tests/libntp/numtoa.c
new file mode 100644
index 000000000000..1d01c7843856
--- /dev/null
+++ b/tests/libntp/numtoa.c
@@ -0,0 +1,31 @@
+#include "config.h"
+
+#include "ntp_stdlib.h"
+#include "ntp_calendar.h"
+#include "ntp_fp.h"
+
+#include "unity.h"
+
+
+void setUp(void)
+{
+}
+
+void tearDown(void)
+{
+}
+
+void test_Address(void) {
+ 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
+ u_int32 hostOrder = 255UL*256UL*256UL*256UL + 255UL*256UL*256UL + 255UL*256UL;
+ u_int32 input = htonl(hostOrder);
+
+ TEST_ASSERT_EQUAL_STRING("255.255.255.0", numtoa(input));
+}
+