atouint.c revision 290001
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
9void test_RegularPositive(void);
10void test_PositiveOverflowBoundary(void);
11void test_PositiveOverflowBig(void);
12void test_Negative(void);
13void test_IllegalChar(void);
14
15
16
17void 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
25void test_PositiveOverflowBoundary(void) {
26	const char *str = "4294967296";
27	u_long actual;
28
29	TEST_ASSERT_FALSE(atouint(str, &actual));
30}
31
32void test_PositiveOverflowBig(void) {
33	const char *str = "8000000000";
34	u_long actual;
35
36	TEST_ASSERT_FALSE(atouint(str, &actual));
37}
38
39void test_Negative(void) {
40	const char *str = "-1";
41	u_long actual;
42
43	TEST_ASSERT_FALSE(atouint(str, &actual));
44}
45
46void test_IllegalChar(void) {
47	const char *str = "50c3";
48	u_long actual;
49
50	TEST_ASSERT_FALSE(atouint(str, &actual));
51}
52