From 96f20bc634334a3bb60206738027255cd1aa1ab8 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 9 Dec 2023 11:31:31 +0100 Subject: [PATCH] Improve test suite --- tests/test-mgeneric.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/test-mgeneric.c b/tests/test-mgeneric.c index 8dd98b42..d96207b7 100644 --- a/tests/test-mgeneric.c +++ b/tests/test-mgeneric.c @@ -27,6 +27,7 @@ #include "m-string.h" #include "m-array.h" +#include "m-list.h" #include "m-generic.h" // Generic is not supported if not C11 @@ -35,6 +36,9 @@ ARRAY_DEF(array_int, int) #define M_OPL_array_int_t() ARRAY_OPLIST(array_int, M_BASIC_OPLIST) +LIST_DEF(list_int, int) +#define M_OPL_list_int_t() LIST_OPLIST(list_int, M_BASIC_OPLIST) + static void h(string_t x) { string_set_str(x, "TEST STRING"); @@ -46,6 +50,7 @@ const string_t gx; #define FLT1 (GENTYPE(float), TYPE(float), INIT(M_INIT_BASIC), INIT_SET(M_SET_BASIC), SET(M_SET_BASIC), \ CLEAR(M_NOTHING_DEFAULT) ) #define ARRAY1 M_OPEXTEND(M_OPL_array_int_t(), GENTYPE(struct array_int_s *)) +#define LIST1 M_OPEXTEND(M_OPL_list_int_t(), GENTYPE(struct list_int_s **)) //#define M_GENERIC_ORG_MLIB_COMP_1() (CORE) //#define M_GENERIC_ORG_MLIB_COMP_CORE_OPLIST_1() STR1 @@ -57,8 +62,10 @@ const string_t gx; #define M_GENERIC_ORG_USER_COMP_CORE_OPLIST_7() STR1 #define M_GENERIC_ORG_3() (ARRAY) -#define M_GENERIC_ORG_ARRAY_COMP_5() (INT) -#define M_GENERIC_ORG_ARRAY_COMP_INT_OPLIST_6() ARRAY1 +#define M_GENERIC_ORG_ARRAY_COMP_5() (AINT) +#define M_GENERIC_ORG_ARRAY_COMP_AINT_OPLIST_6() ARRAY1 +#define M_GENERIC_ORG_ARRAY_COMP_10() (LINT) +#define M_GENERIC_ORG_ARRAY_COMP_LINT_OPLIST_30() LIST1 static bool test_empty(const string_t p) { @@ -98,6 +105,15 @@ static void test_array(void) printf("=%d, ", *it); } } + // Just change the type, same code! + M_LET(a, list_int_t) { + push(a, 14); + push(a, 15); + out_str(stdout, a); + for each(it, a) { + printf("=%d, ", *it); + } + } } int main(void)