]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/ntp/tests/libntp/atouint.c
MFC r280849,280915-280916,281015-281016,282097,282408,282415,283542,
[FreeBSD/stable/10.git] / contrib / ntp / tests / libntp / atouint.c
1 #include "config.h"
2
3 #include "ntp_stdlib.h"
4 #include "ntp_calendar.h"
5 #include "ntp_fp.h"
6
7 #include "unity.h"
8
9 void test_RegularPositive() {
10         const char *str = "305";
11         u_long actual;
12
13         TEST_ASSERT_TRUE(atouint(str, &actual));
14         TEST_ASSERT_EQUAL(305, actual);
15 }
16
17 void test_PositiveOverflowBoundary() {
18         const char *str = "4294967296";
19         u_long actual;
20
21         TEST_ASSERT_FALSE(atouint(str, &actual));
22 }
23
24 void test_PositiveOverflowBig() {
25         const char *str = "8000000000";
26         u_long actual;
27
28         TEST_ASSERT_FALSE(atouint(str, &actual));
29 }
30
31 void test_Negative() {
32         const char *str = "-1";
33         u_long actual;
34
35         TEST_ASSERT_FALSE(atouint(str, &actual));
36 }
37
38 void test_IllegalChar() {
39         const char *str = "50c3";
40         u_long actual;
41
42         TEST_ASSERT_FALSE(atouint(str, &actual));
43 }