-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_sort.c
69 lines (54 loc) · 1.82 KB
/
test_sort.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
#include <pylists4c.h>
int main()
{
LIST* pList = NULL;
LIST* pSortedList = NULL;
listSetFatalMallocErrors(TRUE);
printf("listSorted() test:\n");
printf("==================\n");
pList = list("8, 1, 3, 0, 2, 6, 4, 9, 5, 0, 7");
printf("pList=");
listPrint(pList);
pSortedList = listSorted(pList, FALSE, FALSE, FALSE);
printf("pSortedList=");
listPrint(pSortedList);
listClear(&pSortedList);
pSortedList = listSorted(pList, TRUE, FALSE, FALSE);
printf("pReverseSortedList=");
listPrint(pSortedList);
listClear(&pSortedList);
pSortedList = listSorted(pList, FALSE, FALSE, TRUE);
printf("pNoDupsSortedList=");
listPrint(pSortedList);
listClear(&pSortedList);
printf("pList=");
listPrint(pList);
printf("\nlistSort() test:\n");
printf("================\n");
listSort(&pList, FALSE, FALSE, FALSE);
printf("pList=");
listPrint(pList);
listClear(&pList);
printf("\nStrings:\n");
printf("========\n");
pList = list("'Ken', 'Dennis', 'Brian', 'bill', 'kirk', 'richard', 'linus', 'guido'");
printf("pList=");
listPrint(pList);
pSortedList = listSorted(pList, FALSE, TRUE, FALSE);
printf("pSortedList=");
listPrint(pSortedList);
listClear(&pSortedList);
listClear(&pList);
printf("\nAnd now something not possible with Python:\n");
printf("===========================================\n");
pList = list("'Ken', 43, 'Dennis', 41, 'Brian', 42, 'bill', 54, 'kirk', 54, 'richard', 53, 'linus', 69, 'guido', 57");
printf("pList=");
listPrint(pList);
pSortedList = listSorted(pList, FALSE, TRUE, FALSE);
printf("pSortedList=");
listPrint(pSortedList);
listClear(&pSortedList);
listClear(&pList);
printf("\nAllocated memory: %lu\n", listGetAllocatedMemory());
return 0;
}