From 87afc43c1d8e43322128030d2dc2e000e60aaf4b Mon Sep 17 00:00:00 2001 From: srdja <1875137+srdja@users.noreply.github.com> Date: Sat, 27 Jan 2024 22:46:33 -0800 Subject: [PATCH] Fixing tests Fixing a warning More test fixes --- test/array_sized_test.c | 2 +- test/list_test.c | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/test/array_sized_test.c b/test/array_sized_test.c index 1a9d7a6..88cf95f 100644 --- a/test/array_sized_test.c +++ b/test/array_sized_test.c @@ -932,7 +932,7 @@ static MunitResult test_filter2(const MunitParameter p[], void* fixture) void map_double(uint8_t* e) { int* val = (int*)e; - *e = *e * 2; + *val = *val * 2; } static MunitResult test_map(const MunitParameter p[], void* fixture) diff --git a/test/list_test.c b/test/list_test.c index ae12a16..3c08fd9 100644 --- a/test/list_test.c +++ b/test/list_test.c @@ -1,6 +1,7 @@ #include "munit.h" #include "cc_list.h" #include +#include int cmp(void const* e1, void const* e2) @@ -1075,14 +1076,31 @@ 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)); - bool res; + *a = true; + *b = true; + *c = true; + *d = true; - cc_list_reduce(l->list1, bool_and, &res); + cc_list_add(list, a); + cc_list_add(list, b); + cc_list_add(list, c); + cc_list_add(list, d); + bool res = false; + + cc_list_reduce(list, bool_and, &res); munit_assert_true(res); + cc_list_destroy(list); + return MUNIT_OK; } @@ -1126,7 +1144,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 } };