Self-test implementations.
242{
244 unsigned int array[] = {2, 3, 4, 5, 6};
245
246 assert(
getsize(testList) == 0);
247
248 printf("Testing inserting elements:\n");
249 for (int i = 0; i < 5; ++i)
250 {
253 assert(testList->
value == array[i]);
254 assert(
getsize(testList) == i + 1);
255 }
256
257 printf("\nTesting removing elements:\n");
258 for (int i = 4; i > -1; --i)
259 {
261 assert(testList->
value == array[i]);
263 assert(
getsize(testList) == i);
264 }
265
266 printf("\nTesting inserting at tail:\n");
267 for (int i = 0; i < 5; ++i)
268 {
271 assert(
get(testList, i) == array[i]);
272 assert(
getsize(testList) == i + 1);
273 }
274
275 printf("\nTesting removing from tail:\n");
276 for (int i = 4; i > -1; --i)
277 {
280 assert(
getsize(testList) == i);
281
282
283 if (testList != NULL)
284 {
285 assert(
get(testList, i) == testList->
value);
286 }
287 else
288 {
289
290
291 assert(i == 0);
292 }
293 }
294}
ListNode * delete_from_head(ListNode *head)
Function for deletion of the first node in list.
Definition circular_doubly_linked_list.c:111
void display_list(ListNode *head)
Display list function.
Definition circular_doubly_linked_list.c:191
int getsize(ListNode *head)
The function that will return current size of list.
Definition circular_doubly_linked_list.c:169
ListNode * insert_at_head(ListNode *head, uint64_t data)
Insert a node at start of list.
Definition circular_doubly_linked_list.c:55
ListNode * delete_from_tail(ListNode *head)
Function for deletion of the last node in list.
Definition circular_doubly_linked_list.c:140
uint64_t get(ListNode *list, const int index)
access the list by index
Definition circular_doubly_linked_list.c:223
ListNode * insert_at_tail(ListNode *head, uint64_t data)
Insert a node at end of list.
Definition circular_doubly_linked_list.c:84