From 5f93db596e2407fadf964d79087bd989aa471134 Mon Sep 17 00:00:00 2001 From: lucielle Date: Wed, 10 Jun 2026 09:06:08 -0500 Subject: [PATCH] further cleanup and organization --- Makefile | 3 ++- include/README.md | 1 + include/array.h | 6 +----- include/version.h | 9 +++++++++ test/array.c | 27 +++++++++++++++++++++++++++ test/test.c | 37 +++++++------------------------------ 6 files changed, 47 insertions(+), 36 deletions(-) create mode 100644 include/README.md create mode 100644 include/version.h create mode 100644 test/array.c diff --git a/Makefile b/Makefile index 563c4e6..a32d5ec 100644 --- a/Makefile +++ b/Makefile @@ -7,13 +7,14 @@ CFLAGS = -Wall -Wextra -I$(INCLUDE) -ggdb BUILD_DIR := build TEST_BUILD_DIR := $(BUILD_DIR)/test TEST_BUILD_FILES := $(TEST_BUILD_DIR)/test.o \ + $(TEST_BUILD_DIR)/array.o \ INCLUDE_INSTALL_PATH := /usr/local/include/LTypes all: test test: $(TEST_BUILD_FILES) - $(CC) $(CFLAGS) -o $(TEST_BUILD_DIR)/test $(TEST_BUILD_FILES) + $(CC) $(CFLAGS) -I./test/include -o $(TEST_BUILD_DIR)/test $(TEST_BUILD_FILES) @echo "" $(TEST_BUILD_DIR)/test diff --git a/include/README.md b/include/README.md new file mode 100644 index 0000000..f290a18 --- /dev/null +++ b/include/README.md @@ -0,0 +1 @@ +To use any single header file, either include `version.h` or remove the include from the top. \ No newline at end of file diff --git a/include/array.h b/include/array.h index 316af32..5cf6cb5 100644 --- a/include/array.h +++ b/include/array.h @@ -1,11 +1,7 @@ #ifndef LTYPES_ARRAY_H #define LTYPES_ARRAY_H -#define L_TYPES_AUTHOR "Lucielle typedef struct { diff --git a/include/version.h b/include/version.h new file mode 100644 index 0000000..ff69ada --- /dev/null +++ b/include/version.h @@ -0,0 +1,9 @@ +#ifndef LTYPES_VERSION_H +#define LTYPES_VERSION_H + +#define L_TYPES_AUTHOR "Lucielle + +int test_l_array() { + int RETURN_CODE = 0; + printf("test_l_array() : "); + + LArray* array = l_array_create(); + + int number_1 = 5; + int number_2 = 15; + + l_array_append(array, &number_2); + l_array_append(array, &number_1); + + if (*(int*)array->items[0] != 15) RETURN_CODE++; + if (*(int*)array->items[1] != 5) RETURN_CODE++; + if (array->count != 2) RETURN_CODE++; + if (array->capacity != 8) RETURN_CODE++; + + l_array_clear(array); + if (array->items != NULL) RETURN_CODE++; + + printf("%d\n", RETURN_CODE); + return RETURN_CODE; +} \ No newline at end of file diff --git a/test/test.c b/test/test.c index 89f2bfc..4dd976f 100644 --- a/test/test.c +++ b/test/test.c @@ -1,31 +1,7 @@ #include -#define L_ARRAY_IMPLEMENTATION -#include "../include/array.h" -#include "assert.h" +#include "../include/version.h" -#define TEST_FUNCTION - -static int test_l_array() { - int RETURN_CODE = 0; - - LArray* array = l_array_create(); - - int number_1 = 5; - int number_2 = 15; - - l_array_append(array, &number_2); - l_array_append(array, &number_1); - - assert(*(int*)array->items[0] == 15); - assert(*(int*)array->items[1] == 5); - assert(array->count == 2); - assert(array->capacity == 8); - - l_array_clear(array); - assert(array->items == NULL); - - return RETURN_CODE; -} +int test_l_array(); int main(void) { printf("AUTHOR: %s\n", L_TYPES_AUTHOR); @@ -33,9 +9,10 @@ int main(void) { printf("VERSION: %s\n", L_TYPES_VERSION); printf("LICENSE: %s\n\n", L_TYPES_LICENSE); + int RETURN_CODE = 0; - if ( - test_l_array() - ) return 1; - return 0; + RETURN_CODE += test_l_array(); + + printf("\nError Total: %d\n", RETURN_CODE); + return RETURN_CODE; } \ No newline at end of file