]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/ntp/tests/libntp/atouint.c
Upgrade NTP to 4.2.8p4.
[FreeBSD/releng/10.2.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(void);
10 void test_PositiveOverflowBoundary(void);
11 void test_PositiveOverflowBig(void);
12 void test_Negative(void);
13 void test_IllegalChar(void);
14
15
16
17 void test_RegularPositive(void) {
18         const char *str = "305";
19         u_long actual;
20
21         TEST_ASSERT_TRUE(atouint(str, &actual));
22         TEST_ASSERT_EQUAL(305, actual);
23 }
24
25 void test_PositiveOverflowBoundary(void) {
26         const char *str = "4294967296";
27         u_long actual;
28
29         TEST_ASSERT_FALSE(atouint(str, &actual));
30 }
31
32 void test_PositiveOverflowBig(void) {
33         const char *str = "8000000000";
34         u_long actual;
35
36         TEST_ASSERT_FALSE(atouint(str, &actual));
37 }
38
39 void test_Negative(void) {
40         const char *str = "-1";
41         u_long actual;
42
43         TEST_ASSERT_FALSE(atouint(str, &actual));
44 }
45
46 void test_IllegalChar(void) {
47         const char *str = "50c3";
48         u_long actual;
49
50         TEST_ASSERT_FALSE(atouint(str, &actual));
51 }