chore: allow tests to access internal methods

pull/3/head
Jef Roosens 2023-01-22 10:08:15 +01:00
parent 6823050c2f
commit ef625ed14e
2 changed files with 8 additions and 3 deletions

View File

@ -56,11 +56,15 @@ build-test: $(BINS_TEST)
$(BINS_TEST): %: %.c.o $(OBJS)
$(CC) $^ -o $@
# Each test includes the test directory, which contains the acutest header file
# Allow with the include directory, each test includes $(TEST_DIR) (which
# contains the acutest.h header file), and the src directory of the module it's
# testing. This allows tests to access internal methods, which aren't publicly
# exposed.
$(BUILD_DIR)/$(TEST_DIR)/%.c.o: $(TEST_DIR)/%.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -I$(TEST_DIR) -c $< -o $@
$(CC) $(CFLAGS) -I$(TEST_DIR) \
-I$(dir $(@:$(BUILD_DIR)/$(TEST_DIR)/%=$(SRC_DIR)/%)) \
-c $< -o $@
# =====MAINTENANCE=====
.PHONY: lint

View File

@ -1,5 +1,6 @@
#include "acutest.h"
#include "vieter_heap.h"
#include "vieter_heap_tree.h"
#define TEST_SIZE(heap, size) \
TEST_CHECK(vieter_heap_size(heap) == size); \