diff options
author | Cy Schubert <cy@FreeBSD.org> | 2015-07-01 03:12:13 +0000 |
---|---|---|
committer | Cy Schubert <cy@FreeBSD.org> | 2015-07-01 03:12:13 +0000 |
commit | 873997f35a991eee09ed91148a0cf332360380da (patch) | |
tree | 5b1ffa3ad0e56e0e9f2991011729791ee86d7632 /tests/libntp/atouint.c | |
parent | 4ba32eb5a8bf3455c09d1513ed2af8d2c861a6ba (diff) |
Notes
Diffstat (limited to 'tests/libntp/atouint.c')
-rw-r--r-- | tests/libntp/atouint.c | 43 |
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)); +} |