Skip to content

Commit

Permalink
Fixing a bad test
Browse files Browse the repository at this point in the history
  • Loading branch information
srdja committed Jan 28, 2024
1 parent eb4bc3b commit efc5443
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions test/list_test.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "munit.h"
#include "cc_list.h"
#include <stdlib.h>
#include <stdbool.h>


int cmp(void const* e1, void const* e2)
Expand Down Expand Up @@ -1075,14 +1076,27 @@ static MunitResult test_reduce1(const MunitParameter params[], void* fixture)

static MunitResult test_reduce2(const MunitParameter params[], void* fixture)
{
struct lists* l = (struct lists*)fixture;
CC_List* list;
cc_list_new(&list);

bool* a = (bool*)malloc(sizeof(int));
bool* b = (bool*)malloc(sizeof(int));
bool* c = (bool*)malloc(sizeof(int));
bool* d = (bool*)malloc(sizeof(int));

*a = true;
*b = true;
*c = true;
*d = true;

bool res;

cc_list_reduce(l->list1, bool_and, &res);
cc_list_reduce(list, bool_and, &res);

munit_assert_true(res);

cc_list_destroy(list);

return MUNIT_OK;
}

Expand Down Expand Up @@ -1126,7 +1140,7 @@ static MunitTest test_suite_tests[] = {
{(char*)"/list/test_filter1", test_filter1, pre_filled_lists, lists_teardown, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/list/test_filter2", test_filter2, pre_filled_lists, lists_teardown, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/list/test_reduce1", test_reduce1, pre_filled_lists, lists_teardown, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/list/test_reduce2", test_reduce2, pre_filled_lists, lists_teardown, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/list/test_reduce2", test_reduce2, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{ NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }
};

Expand Down

0 comments on commit efc5443

Please sign in to comment.