-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_insertSorted.c
115 lines (85 loc) · 2.76 KB
/
test_insertSorted.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
#include <pylists4c.h>
int main()
{
LIST* pList = NULL;
long v;
listSetFatalMallocErrors(TRUE);
/************/
pList = list("2, 4, 6, 8");
listPrint(pList);
printf("Insert 0\n");
v = 0;
listInsertSorted(&pList, &v, ETYPE_LONG, sizeof(v), FALSE, FALSE, FALSE);
listPrint(pList);
printf("Insert 5\n");
v = 5;
listInsertSorted(&pList, &v, ETYPE_LONG, sizeof(v), FALSE, FALSE, FALSE);
listPrint(pList);
printf("Insert 10\n");
v = 10;
listInsertSorted(&pList, &v, ETYPE_LONG, sizeof(v), FALSE, FALSE, FALSE);
listPrint(pList);
listClear(&pList);
printf("\n");
/************/
pList = list("8, 6, 4, 2");
listPrint(pList);
printf("Insert 0 in reverse order\n");
v = 0;
listInsertSorted(&pList, &v, ETYPE_LONG, sizeof(v), TRUE, FALSE, FALSE);
listPrint(pList);
printf("Insert 5 in reverse order\n");
v = 5;
listInsertSorted(&pList, &v, ETYPE_LONG, sizeof(v), TRUE, FALSE, FALSE);
listPrint(pList);
printf("Insert 10 in reverse order\n");
v = 10;
listInsertSorted(&pList, &v, ETYPE_LONG, sizeof(v), TRUE, FALSE, FALSE);
listPrint(pList);
listClear(&pList);
printf("\n");
/************/
pList = list("'B', 'D', 'F', 'b', 'd', 'f'");
listPrint(pList);
printf("Insert 'A'\n");
listInsertSorted(&pList, "A", ETYPE_STRING, 2, FALSE, FALSE, FALSE);
listPrint(pList);
printf("Insert 'a'\n");
listInsertSorted(&pList, "a", ETYPE_STRING, 2, FALSE, FALSE, FALSE);
listPrint(pList);
printf("Insert 'g'\n");
listInsertSorted(&pList, "g", ETYPE_STRING, 2, FALSE, FALSE, FALSE);
listPrint(pList);
listClear(&pList);
printf("\n");
/************/
pList = list("'B', 'd', 'F'");
listPrint(pList);
printf("Insert 'a' case insensitive\n");
listInsertSorted(&pList, "a", ETYPE_STRING, 2, FALSE, TRUE, FALSE);
listPrint(pList);
printf("Insert 'E' case insensitive\n");
listInsertSorted(&pList, "E", ETYPE_STRING, 2, FALSE, TRUE, FALSE);
listPrint(pList);
printf("Insert 'g' case insensitive\n");
listInsertSorted(&pList, "g", ETYPE_STRING, 2, FALSE, TRUE, FALSE);
listPrint(pList);
listClear(&pList);
printf("\n");
/************/
pList = list("4, 6, 8");
listPrint(pList);
printf("Insert 2 no duplicates\n");
listInsertSortedLong(&pList, 2, FALSE, FALSE, TRUE);
listPrint(pList);
printf("Insert 6 no duplicates\n");
listInsertSortedLong(&pList, 6, FALSE, FALSE, TRUE);
listPrint(pList);
printf("Insert 10 no duplicates\n");
listInsertSortedLong(&pList, 10, FALSE, FALSE, TRUE);
listPrint(pList);
listClear(&pList);
printf("\n");
printf("Allocated memory: %lu\n", listGetAllocatedMemory());
return 0;
}