further cleanup and organization

This commit is contained in:
2026-06-10 09:06:08 -05:00
parent 7350a8cdfc
commit 5f93db596e
6 changed files with 47 additions and 36 deletions

View File

@@ -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

1
include/README.md Normal file
View File

@@ -0,0 +1 @@
To use any single header file, either include `version.h` or remove the include from the top.

View File

@@ -1,11 +1,7 @@
#ifndef LTYPES_ARRAY_H
#define LTYPES_ARRAY_H
#define L_TYPES_AUTHOR "Lucielle <luci@git.lunarware.tech"
#define L_TYPES_REPO "https://git.lunarware.tech/lucielle/ltypes.git"
#define L_TYPES_VERSION "0.1.0"
#define L_TYPES_LICENSE "GNU GPL v3"
#include "version.h"
#include <stddef.h>
typedef struct {

9
include/version.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef LTYPES_VERSION_H
#define LTYPES_VERSION_H
#define L_TYPES_AUTHOR "Lucielle <luci@git.lunarware.tech"
#define L_TYPES_REPO "https://git.lunarware.tech/lucielle/ltypes.git"
#define L_TYPES_VERSION "0.1.0"
#define L_TYPES_LICENSE "GNU GPL v3"
#endif

27
test/array.c Normal file
View File

@@ -0,0 +1,27 @@
#define L_ARRAY_IMPLEMENTATION
#include "../include/array.h"
#include <stdio.h>
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;
}

View File

@@ -1,31 +1,7 @@
#include <stdio.h>
#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;
}