-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_ctype.c
132 lines (108 loc) · 2.16 KB
/
test_ctype.c
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include "stdio.h"
#include "ctype.h"
#include "test.h"
//
static void test_islower()
{
SUITE("islower");
TEST(TRUE == islower('a'));
TEST(TRUE == islower('z'));
TEST(FALSE == islower('A'));
TEST(FALSE == islower('Z'));
TEST(FALSE == islower('1'));
}
//
static void test_isupper()
{
SUITE("islower");
TEST(TRUE == isupper('A'));
TEST(TRUE == isupper('Z'));
TEST(FALSE == isupper('a'));
TEST(FALSE == isupper('z'));
TEST(FALSE == isupper('1'));
}
//
static void test_isalpha()
{
SUITE("isalpha");
TEST(TRUE == isalpha('A'));
TEST(TRUE == isalpha('a'));
TEST(TRUE == isalpha('Z'));
TEST(TRUE == isalpha('a'));
TEST(FALSE == isalpha('0'));
TEST(FALSE == isalpha('9'));
TEST(FALSE == isalpha('-'));
}
//
static void test_isdigit()
{
SUITE("isdigit");
TEST(TRUE == isdigit('0'));
TEST(TRUE == isdigit('9'));
TEST(FALSE == isdigit('A'));
TEST(FALSE == isdigit('a'));
TEST(FALSE == isdigit('Z'));
TEST(FALSE == isdigit('a'));
}
//
static void test_isalnum()
{
SUITE("isalnum");
TEST(TRUE == isalnum('0'));
TEST(TRUE == isalnum('9'));
TEST(TRUE == isalnum('A'));
TEST(TRUE == isalnum('a'));
TEST(TRUE == isalnum('Z'));
TEST(TRUE == isalnum('a'));
TEST(FALSE == isalnum('-'));
TEST(FALSE == isalnum('@'));
TEST(FALSE == isalnum('&'));
}
//
static void test_tolower()
{
SUITE("tolower");
TEST('a' == tolower('A'));
TEST('z' == tolower('Z'));
TEST('a' == tolower('a'));
TEST('z' == tolower('z'));
TEST('0' == tolower('0'));
TEST('9' == tolower('9'));
TEST('@' == tolower('@'));
}
//
static void test_toupper()
{
SUITE("toupper");
TEST('A' == toupper('A'));
TEST('Z' == toupper('Z'));
TEST('A' == toupper('a'));
TEST('Z' == toupper('z'));
TEST('0' == toupper('0'));
TEST('9' == toupper('9'));
TEST('@' == toupper('@'));
}
//
static void test_isspace()
{
SUITE("isspace");
TEST(TRUE == isspace(' '));
TEST(TRUE == isspace('\f'));
TEST(TRUE == isspace('\t'));
TEST(TRUE == isspace('\n'));
TEST(TRUE == isspace('\r'));
TEST(FALSE == isspace('a'));
TEST(FALSE == isspace('0'));
}
//
void test_ctype()
{
test_islower();
test_isupper();
test_isalpha();
test_isdigit();
test_isalnum();
test_tolower();
test_toupper();
test_isspace();
}