-
Notifications
You must be signed in to change notification settings - Fork 2
/
ListTest.c
141 lines (125 loc) · 3.73 KB
/
ListTest.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
133
134
135
136
137
138
139
140
141
/**********************************************************************************
*
* Raj Maitra
* Rmaitra
* Assignment: pa5
*
***********************************************************************************/
#include<stdio.h>
#include"List.h"
int main(int argc, char* argv[]){
int i;
ListRef A = newList();
ListRef B = newList();
ListRef X = NULL;
/* Test Initialized Access Functions */
printf("---------------Test Initializations:----------------\n");
printf("Index\n");
printf("%d\n", getIndex(A));
printf("Length\n");
printf("%d\n\n", getLength(A));
/* Test Insertion Back and Insertion Front */
printf("---------------Test Insertion Back and Front:----------------\n");
printf("Inserting Back for List A and Front for List B...\n");
for(i=1; i<=6; i++){
insertBack(A, i);
insertFront(B, i);
printflist(A);
printflist(B);
}
printf("Inserting Front for List A and Back for List B...\n");
for(i=1; i<=6; i++){
insertFront(A, i);
insertBack(B, i);
printflist(A);
printflist(B);
}
/* Test Move To */
printf("------------------Test moveTo:-----------------------\n");
printf("Move A to index:3\n");
moveTo(A, 3);
printf("%d\n", getIndex(A));
printf("Move B to index:9\n");
moveTo(B, 9);
printf("%d\n\n", getIndex(B));
/* Test Current Marker Functions */
printf("----------------Test current:---------------------\n");
printf("getCurrent(A) should be index 3:\n");
printflist(A);
printf("%d\n", getCurrent(A));
printf("getCurrent(B) should be index 9:\n");
printflist(B);
printf("%d\n\n", getCurrent(B));
/* Test Equals Function */
printf("----------------Test Equals:---------------------\n");
printf("equals(A,B)?\n");
printf("%s\n", equals(A,B)?"true":"false");
printf("equals(A,A)?\n");
printf("%s\n", equals(A,A)?"true":"false");
printf("\n");
/* Test delete Back, Front and Current Functions */
printf("----------------Test Delete Functions:---------------------\n");
printf("deleteCurrent A and B\n");
printflist(A);
printflist(B);
deleteCurrent(A);
deleteCurrent(B);
printflist(A);
printflist(B);
printf("deleteBack A and B\n");
printflist(A);
printflist(B);
deleteBack(A);
deleteBack(B);
printflist(A);
printflist(B);
printf("deleteFront A and B\n");
printflist(A);
printflist(B);
deleteFront(A);
deleteFront(B);
printflist(A);
printflist(B);
/* Test insert Current Before and After List */
printf("----------------Test insertCurrent Before and After:---------------------\n");
printf("Move A to index:2\n");
moveTo(A, 2);
printf("%d\n", getIndex(A));
printf("Move B to index:4\n");
moveTo(B, 4);
printf("%d\n\n", getIndex(B));
printf("insertCurrentBefore A\n");
insertBeforeCurrent(A, 99);
printf("insertCurrentBefore B\n");
insertBeforeCurrent(B, 99);
printflist(A);
printflist(B);
printf("insertCurrentAfter A\n");
insertAfterCurrent(A, 44);
printf("insertCurrentAfter B\n");
insertAfterCurrent(B, 44);
printflist(A);
printflist(B);
/* Test makeEmpty List */
printf("----------------Test makeEmpty:---------------------\n");
printf("Length of A:%d\n", getLength(A));
printf("Length of B:%d\n", getLength(B));
X = copyList(A);
makeEmpty(A);
makeEmpty(B);
printflist(A);
printflist(B);
/* Test makeEmpty List */
printf("----------------Test Last Insert:---------------------\n");
insertBack(A, 1);
insertBack(B, 8);
printflist(A);
printflist(B);
/* Test copy List */
printf("----------------Test Copy List:---------------------\n");
printflist(X);
freeList(&X);
freeList(&B);
freeList(&A);
return(0);
}