Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing a test for List_clear_destroy() #37

Open
zolodev opened this issue Mar 30, 2023 · 0 comments
Open

Missing a test for List_clear_destroy() #37

zolodev opened this issue Mar 30, 2023 · 0 comments

Comments

@zolodev
Copy link

zolodev commented Mar 30, 2023

The Problem

Missing a test to check if the code actually worked or not.

char *test_destroy()
{
List_clear_destroy(list);
return NULL;
}

My Approach

Learning from p. 149 "Question Authority". 😉
Using TDD (see attached image), where I first write the test-cases first I stumbled upon a bug in the lists_tests.c file.

image

The code will not really test if the list has been cleared and destroyed.
The test will PASS by just adding the following minimal implementation function to list.c

void *List_clear_destroy(List *list) {
  return (list);
}

Suggested Solution

I suggest adding a test using mu_assert(), to actually test the list variable.
Now I do not know if there is any better way to test this, but at least it is testing something. 😄

 char *test_destroy() 
 { 
     List_clear_destroy(list); 
     
     // Add the following test 
     mu_assert(list->count == 0, "Failed to clear list");

     return NULL; 
 } 

What do you think @zedshaw ?
Do you have a better way to test and check if the list is empty, please let me know because I am very curious about how that could be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant