summaryrefslogtreecommitdiff
path: root/tests/libntp/atouint.c
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2015-07-01 03:12:13 +0000
committerCy Schubert <cy@FreeBSD.org>2015-07-01 03:12:13 +0000
commit873997f35a991eee09ed91148a0cf332360380da (patch)
tree5b1ffa3ad0e56e0e9f2991011729791ee86d7632 /tests/libntp/atouint.c
parent4ba32eb5a8bf3455c09d1513ed2af8d2c861a6ba (diff)
Notes
Diffstat (limited to 'tests/libntp/atouint.c')
-rw-r--r--tests/libntp/atouint.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/libntp/atouint.c b/tests/libntp/atouint.c
new file mode 100644
index 0000000000000..33c15a9141c33
--- /dev/null
+++ b/tests/libntp/atouint.c
@@ -0,0 +1,43 @@
+#include "config.h"
+
+#include "ntp_stdlib.h"
+#include "ntp_calendar.h"
+#include "ntp_fp.h"
+
+#include "unity.h"
+
+void test_RegularPositive() {
+ const char *str = "305";
+ u_long actual;
+
+ TEST_ASSERT_TRUE(atouint(str, &actual));
+ TEST_ASSERT_EQUAL(305, actual);
+}
+
+void test_PositiveOverflowBoundary() {
+ const char *str = "4294967296";
+ u_long actual;
+
+ TEST_ASSERT_FALSE(atouint(str, &actual));
+}
+
+void test_PositiveOverflowBig() {
+ const char *str = "8000000000";
+ u_long actual;
+
+ TEST_ASSERT_FALSE(atouint(str, &actual));
+}
+
+void test_Negative() {
+ const char *str = "-1";
+ u_long actual;
+
+ TEST_ASSERT_FALSE(atouint(str, &actual));
+}
+
+void test_IllegalChar() {
+ const char *str = "50c3";
+ u_long actual;
+
+ TEST_ASSERT_FALSE(atouint(str, &actual));
+}