From 0d999f5b3960622011d96fd3e4deef9f4673cfcb Mon Sep 17 00:00:00 2001 From: r4 Date: Sun, 29 May 2022 21:53:25 +0200 Subject: [PATCH] make vec test split into .h and .c files --- Makefile | 4 +++- include/ds/generic/map.h | 2 ++ tests/generic/vec.c | 7 ++----- tests/generic/vec.h | 9 +++++++++ 4 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 tests/generic/vec.h diff --git a/Makefile b/Makefile index e85a1ce..7de3353 100644 --- a/Makefile +++ b/Makefile @@ -50,8 +50,10 @@ else \ fi endef +TEST_HDR := generic/vec.h TESTS := generic/map generic/smap generic/vec error fmt +_TEST_HDR := $(addprefix tests/,$(TEST_HDR)) _TESTS := $(addsuffix $(EXE_EXT),$(addprefix tests/,$(TESTS))) .PHONY: test test_outputs test_leaks test_full test_debug @@ -77,7 +79,7 @@ else @echo "Options are: $(TESTS)" endif -tests/%: tests/%.c ds.a $(_HDR) +tests/%: tests/%.c ds.a $(_HDR) $(_TEST_HDR) $(CC) -o $@ $< ds.a -I./include $(CFLAGS) $(LDFLAGS) ################################ diff --git a/include/ds/generic/map.h b/include/ds/generic/map.h index db53196..48fef60 100644 --- a/include/ds/generic/map.h +++ b/include/ds/generic/map.h @@ -54,6 +54,8 @@ FUNCDECL(bool, _del)(NAME m, KTYPE key); FUNCDECL(Error, _rehash)(NAME *m, size_t new_minimum_cap); FUNCDECL(bool, _it_next)(NAME m, ITEM_TYPE **restrict it); +VARDEF(const char *, test_string_lol) = NULL; + #ifdef GENERIC_IMPL VARDEF(const char *, __val_fmt) = NULL; VARDEF(const char *, __key_fmt) = NULL; diff --git a/tests/generic/vec.c b/tests/generic/vec.c index 1b8c6f8..f483528 100644 --- a/tests/generic/vec.c +++ b/tests/generic/vec.c @@ -1,12 +1,9 @@ // Copyright 2022 Darwin Schuppan // SPDX license identifier: MIT -#define GENERIC_IMPL_STATIC +#define GENERIC_IMPL -#define GENERIC_TYPE int -#define GENERIC_NAME IntVec -#define GENERIC_PREFIX int_vec -#include +#include "vec.h" #include #include diff --git a/tests/generic/vec.h b/tests/generic/vec.h new file mode 100644 index 0000000..b878dfe --- /dev/null +++ b/tests/generic/vec.h @@ -0,0 +1,9 @@ +#ifndef __TESTS_VEC_H__ +#define __TESTS_VEC_H__ + +#define GENERIC_TYPE int +#define GENERIC_NAME IntVec +#define GENERIC_PREFIX int_vec +#include + +#endif