-
Notifications
You must be signed in to change notification settings - Fork 0
/
listdr.c
122 lines (95 loc) · 2.56 KB
/
listdr.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
/*
* ORIGINALLY CREATED BY
*
* Nico Williams AND Samuel Reha
* nijowill sreha
* 4/18/2014 4/18/2014
*
* Modified by Nico Williams
* and Joseph Rogers on 5/02/2014
*
* Modified by Nico Williams on
* 5/23/2014
*
* Modified by Nico Williams (nijowill) and
* Patrick Russell (pcrussel) on
* 06/06/2014
*
* This program test all the functions and edge cases
* of those functions for the linked list created by
* raryList.c
*
*This program utilises myinclude.h, list.h
*
*/
/*
* Driver program for the List module.
* The purpose of this is not to do anything "interesting"
* but rather to test out and make sure that the List
* ADT implementation is working properly.
*/
#include "myinclude.h"
#include "list.h"
int main (){
/***Exercise List constructor***/
ListHndl List;
List = NULL;
List = newList ();
if(List){
printf("List Created\n");
}else{
printf("List Not Created\n");
}
printf("isEmpty %d\n",isEmpty(List)); /*should print 1*/
/***Populate with test data***/
int i;
for(i=0; i<=4; i++){
insertAtFront(List,i);
}
printList(stdout, List);
printf("isEmpty %d\n",isEmpty(List)); /*should print 0*/
int j;
for(j=5; j<=9; j++){
insertAtBack(List,j);
}
printList(stdout, List);
/***Exercise all access functions***/
printf("offEnd %d\n",offEnd(List));/*should print 0*/
printf("atFirst %d\n",atFirst(List));/*should print 0*/
printf("atLast %d\n",atLast(List));/*should print 0*/
printf("getFirst %d\n", getFirst(List));/*should print 4*/
printf("getLast %d\n", getLast(List));/*should print 9*/
printf("getCurrent %d\n", getCurrent(List));/*should print 0*/
/***Exercise all removal manipulation functions***/
deleteLast(List);
printList(stdout, List);
printf("getLast %d\n", getLast(List));/*should print 8*/
deleteFirst(List);
printList(stdout, List);
printf("getFirst \n", getFirst(List));/*should print 3*/
deleteCurrent(List);
printList(stdout, List);
moveLast(List);
printList(stdout, List);
movePrev(List);
printList(stdout, List);
moveNext(List);
printList(stdout, List);
/***Exercise various edge cases***/
makeEmpty(List);
insertAtFront(List, 40);
moveFirst(List);
deleteCurrent(List);
insertAtFront(List, 41);
insertAtBack(List, 42);
moveFirst(List);
insertBeforeCurrent(List, 43);
printList(stdout, List);
/***Exercise List destructors***/
deleteCurrent(List);
printList(stdout, List);
makeEmpty(List);
printf("offEnd %d\n",offEnd(List));/*should print 1*/
freeList(&List);
return(0);
}