From 8bddbe6a7cf4d635c5fd4edfe3f48a456e1e595a Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 26 Dec 2021 18:30:57 +0000 Subject: [PATCH] Add test for List_remove() --- src/test/test.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/test/test.c b/src/test/test.c index 04d2683..2132de8 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -164,6 +164,27 @@ void shouldCopyEmptyList() { printSuccess(__func__); } +void shouldRemoveElementFromList() { + // Arrange + List *list = List_new(); + List_append(list, 0); + List_append(list, 1); + List_append(list, 2); + List_append(list, 0); + + // Act + List_remove(list, 0); + + // Assert + assert(List_length(list) == 3); + assert(List_get(list, 0) == 1); + assert(List_get(list, 1) == 2); + assert(List_get(list, 2) == 0); + List_destroy(&list); + + printSuccess(__func__); +} + int main() { printf("============================================"); printf("\nSTART TESTING"); @@ -176,6 +197,7 @@ int main() { shouldCopyPopulatedList(); shouldCopyEmptyList(); shouldInsertElementIntoListIndexZero(); + shouldRemoveElementFromList(); printf("\n\n============================================"); printf("\nFINISH TESTING"); printf("\n============================================");