Add CT331 Programming Paradigms

This commit is contained in:
2023-12-07 01:33:53 +00:00
parent 38a012c323
commit 262614ce83
207 changed files with 4516 additions and 0 deletions

View File

@ -0,0 +1,57 @@
#include <stdio.h>
#include "tests.h"
#include "linkedList.h"
void runTests(){
printf("Tests running...\n");
listElement* l = createEl("Test String (1).", sizeof("Test String (1)."));
//printf("%s\n%p\n", l->data, l->next);
//Test create and traverse
traverse(l);
printf("\n");
//Test insert after
printf("Testing insertAfter()\n");
listElement* l2 = insertAfter(l, "another string (2)", sizeof("another test string(2)"));
insertAfter(l2, "a final string (3)", sizeof("a final string(3)"));
traverse(l);
printf("\n");
// test length function
printf("Testing length()\n");
int l_length = length(l);
printf("The length of l is %d\n\n", l_length);
// test push
printf("Testing push()\n");
push(&l, "yet another test string", sizeof("yet another test string"));
traverse(l);
printf("\n\n");
// test pop
printf("Testing pop()\n");
listElement* popped = pop(&l);
traverse(l);
printf("\n\n");
// Test delete after
printf("Testing deleteAfter()\n");
deleteAfter(l);
traverse(l);
printf("\n");
// test enqueue
printf("Testing enqueue()\n");
enqueue(&l, "enqueued test string", sizeof("enqueued test string"));
traverse(l);
printf("\n");
// test dequeue
printf("Testing dequeue()\n");
dequeue(l);
traverse(l);
printf("\n");
printf("\nTests complete.\n");
}