-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.c
74 lines (60 loc) · 1.39 KB
/
test.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
#include "regex_matcher.c"
int main() {
return test_nfa();
}
int test_nfa() {
bool b = simple_match("a(b*|c)", "abcdf");
if (b == TRUE) {
printf("simple_match success. \n");
} else {
printf("simple_match fail. \n");
}
return 0;
}
int test_stack() {
Stack* stack = ilib_stack_newstack();
ilib_stack_push(stack, 0);
ilib_stack_push(stack, 1);
ilib_stack_push(stack, 2);
ilib_stack_push(stack, 3);
printf("%d\n", ilib_stack_pop(stack));
printf("%d\n", ilib_stack_pop(stack));
printf("%d\n", ilib_stack_pop(stack));
printf("%d\n", ilib_stack_pop(stack));
ilib_stack_destroystack(stack, FALSE);
return 0;
}
int test_list(){
List * list = ilib_list_newlist();
char *str1 = "111\n";
char *str2 = "222\n";
char *str3 = "333\n";
char *str4 = "444\n";
ilib_list_add(list, str1, 0);
ilib_list_add(list, str2, 1);
ilib_list_add(list, str3, 2);
ilib_list_add(list, str4, 3);
for (int i = 0; i < list -> list_size; i++) {
printf(ilib_list_get(list, i));
}
}
int test_strctr() {
char *string = "1234567890";
CtrlString* str = strctr_init(string);
char c;
char opt;
while (TRUE) {
scanf("%c", &opt);
if (opt == 'n') {
if ((c = strctr_next(str)) != '\0') {
printf("%c\n", c);
} else {
break;
}
} else if (opt == 'b') {
strctr_rollback(str);
}
}
strctr_recycle(str);
return 0;
}