From e2287cfe1b7208cdf046abef139c9426351ddbba Mon Sep 17 00:00:00 2001 From: JP Appel Date: Mon, 22 Jul 2024 15:20:23 -0400 Subject: renamed file and log function --- Makefile | 2 +- eztester.c | 2 +- eztester.h | 4 ++-- eztester_list.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ test_list.c | 55 ------------------------------------------------------- 5 files changed, 59 insertions(+), 59 deletions(-) create mode 100644 eztester_list.c delete mode 100644 test_list.c diff --git a/Makefile b/Makefile index fe11165..3b123e1 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ DEBUG_FLAGS := -ggdb -Og VERSION:= 0.1 BUILD_DIR := build -SRCS := eztester.c test_list.c +SRCS := eztester.c eztester_list.c STATIC_OBJS := $(addprefix $(BUILD_DIR)/static/,$(SRCS:.c=.o)) DYNAMIC_OBJS := $(addprefix $(BUILD_DIR)/dynamic/,$(SRCS:.c=.o)) STATIC_LIBS := $(BUILD_DIR)/static/libeztester.a $(BUILD_DIR)/static/libeztester_debug.a diff --git a/eztester.c b/eztester.c index 0964e7c..55b51c4 100644 --- a/eztester.c +++ b/eztester.c @@ -197,7 +197,7 @@ void eztester_run(eztester_list *test_list, eztester_behavior behavior) { } } -void eztester_test_print(const char *restrict format, ...) { +void eztester_log(const char *restrict format, ...) { va_list args; va_start(args, format); printf("> "); diff --git a/eztester.h b/eztester.h index 9133a02..09f6097 100644 --- a/eztester.h +++ b/eztester.h @@ -39,8 +39,8 @@ void eztester_clear_list(eztester_list *test_list); // clears a list and free's the list void eztester_destroy_list(eztester_list *test_list); -// print during a test -void eztester_test_print(const char *__restrict format, ...); +// log info during a test +void eztester_log(const char *__restrict format, ...); // run all tests with a list with a given behavior void eztester_run(eztester_list *test_list, const eztester_behavior behavior); diff --git a/eztester_list.c b/eztester_list.c new file mode 100644 index 0000000..bac6fc2 --- /dev/null +++ b/eztester_list.c @@ -0,0 +1,55 @@ +#include "eztester.h" + +#include +#include + +eztester_list *eztester_create_list(const size_t capacity) { + eztester_list *list = malloc(sizeof(eztester_list)); + if (!list) { + return NULL; + } + + list->length = 0; + + if (capacity == 0) { + list->tests = NULL; + list->capacity = 0; + return list; + } + + eztester_test *tests = malloc(capacity * sizeof(eztester_test)); + if (!tests) { + free(list); + return NULL; + } + list->tests = tests; + + list->capacity = capacity; + return list; +} + +void eztester_register(eztester_list *test_list, const eztester_test new_test) { + if (test_list->capacity == 0) { + test_list->tests = realloc(test_list->tests, 2 * sizeof(eztester_test)); + test_list->capacity = 2; + } + if (test_list->capacity <= test_list->length + 1) { + test_list->capacity *= 2; + test_list->tests = + realloc(test_list->tests, test_list->capacity * sizeof(eztester_test)); + assert(test_list->tests); + } + + test_list->tests[test_list->length++] = new_test; +} + +void eztester_clear_list(eztester_list *test_list) { + free(test_list->tests); + test_list->length = 0; + test_list->capacity = 0; +} + +void eztester_destroy_list(eztester_list *test_list) { + eztester_clear_list(test_list); + free(test_list); +} diff --git a/test_list.c b/test_list.c deleted file mode 100644 index bac6fc2..0000000 --- a/test_list.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "eztester.h" - -#include -#include - -eztester_list *eztester_create_list(const size_t capacity) { - eztester_list *list = malloc(sizeof(eztester_list)); - if (!list) { - return NULL; - } - - list->length = 0; - - if (capacity == 0) { - list->tests = NULL; - list->capacity = 0; - return list; - } - - eztester_test *tests = malloc(capacity * sizeof(eztester_test)); - if (!tests) { - free(list); - return NULL; - } - list->tests = tests; - - list->capacity = capacity; - return list; -} - -void eztester_register(eztester_list *test_list, const eztester_test new_test) { - if (test_list->capacity == 0) { - test_list->tests = realloc(test_list->tests, 2 * sizeof(eztester_test)); - test_list->capacity = 2; - } - if (test_list->capacity <= test_list->length + 1) { - test_list->capacity *= 2; - test_list->tests = - realloc(test_list->tests, test_list->capacity * sizeof(eztester_test)); - assert(test_list->tests); - } - - test_list->tests[test_list->length++] = new_test; -} - -void eztester_clear_list(eztester_list *test_list) { - free(test_list->tests); - test_list->length = 0; - test_list->capacity = 0; -} - -void eztester_destroy_list(eztester_list *test_list) { - eztester_clear_list(test_list); - free(test_list); -} -- cgit v1.2.3