blob: e640c36d0fb93a2523149a56decb3ea5a3da2500 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#include "config.h"
#include "ntp_stdlib.h"
#include "ntp_calendar.h"
#include "unity.h"
void test_RegularPositive(void);
void test_RegularNegative(void);
void test_PositiveOverflowBoundary(void);
void test_NegativeOverflowBoundary(void);
void test_PositiveOverflowBig(void);
void test_IllegalCharacter(void);
void test_RegularPositive(void) {
const char *str = "17";
long val;
TEST_ASSERT_TRUE(atoint(str, &val));
TEST_ASSERT_EQUAL(17, val);
}
void test_RegularNegative(void) {
const char *str = "-20";
long val;
TEST_ASSERT_TRUE(atoint(str, &val));
TEST_ASSERT_EQUAL(-20, val);
}
void test_PositiveOverflowBoundary(void) {
const char *str = "2147483648";
long val;
TEST_ASSERT_FALSE(atoint(str, &val));
}
void test_NegativeOverflowBoundary(void) {
const char *str = "-2147483649";
long val;
TEST_ASSERT_FALSE(atoint(str, &val));
}
void test_PositiveOverflowBig(void) {
const char *str = "2300000000";
long val;
TEST_ASSERT_FALSE(atoint(str, &val));
}
void test_IllegalCharacter(void) {
const char *str = "4500l";
long val;
TEST_ASSERT_FALSE(atoint(str, &val));
}
|