diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..0bd0ddf --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,81 @@ +# This software is licensed by the MIT License, see LICENSE file +# Copyright © 2022 Gregory Lirent + +######################################################################################################################## + +BUILD_PATH ?= ./bin + +######################################################################################################################## + +CC = clang +MKDIR = mkdir -p +RMRF = rm -rf +AR = ar crs +CP = cp + +$(BUILD_PATH)/obj/%.o: CFLAGS := $(CFLAGS) -Og -fPIC -c -g3 -Wall + +######################################################################################################################## + + +c_objects = $(addsuffix .o,$(addprefix $(2),$(notdir $(basename $(wildcard $(1)*.c))))) + +OBJECTS_TESTS := $(call c_objects,./src/,) +OBJECTS_BASE := $(call c_objects,../src/,) +OBJECTS_STRING := $(OBJECTS_BASE) $(call c_objects,../src/string/,string-) +OBJECTS_ARRAY := $(OBJECTS_BASE) $(call c_objects,../src/array/,array-) +OBJECTS_LIST := $(OBJECTS_BASE) $(call c_objects,../src/list/,list-) +OBJECTS_MAP := $(OBJECTS_BASE) $(call c_objects,../src/map/,map-) +OBJECTS_SET := $(OBJECTS_BASE) $(call c_objects,../src/set/,set-) + +OBJECTS_BASE := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_BASE)) +OBJECTS_STRING := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_STRING)) +OBJECTS_ARRAY := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_ARRAY)) +OBJECTS_LIST := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_LIST)) +OBJECTS_MAP := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_MAP)) +OBJECTS_SET := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_SET)) + +######################################################################################################################## + +tests: modules +tests: $(BUILD_PATH)/array +tests: $(BUILD_PATH)/string +tests: $(BUILD_PATH)/list +tests: $(BUILD_PATH)/map +tests: $(BUILD_PATH)/set + +######################################################################################################################## + +$(BUILD_PATH)/obj/%.o: ./src/%.c | $(BUILD_PATH)/obj/ + $(CC) $^ -o $@ $(CFLAGS) + +$(BUILD_PATH)/array: ./src/array/main.c $(OBJECTS_ARRAY) | $(BUILD_PATH)/ + $(CC) $^ -o $@ $(CFLAGS) +$(BUILD_PATH)/string: ./src/string/main.c $(OBJECTS_STRING) | $(BUILD_PATH)/ + $(CC) $^ -o $@ ../modules/libunic/bin/libunic.a $(CFLAGS) +$(BUILD_PATH)/list: ./src/list/main.c $(OBJECTS_LIST) | $(BUILD_PATH)/ + $(CC) $^ -o $@ $(CFLAGS) +$(BUILD_PATH)/map: ./src/map/main.c $(OBJECTS_MAP) | $(BUILD_PATH)/ + $(CC) $^ -o $@ $(CFLAGS) +$(BUILD_PATH)/set: ./src/set/main.c $(OBJECTS_SET) | $(BUILD_PATH)/ + $(CC) $^ -o $@ $(CFLAGS) + +######################################################################################################################## + +$(BUILD_PATH)/: + $(MKDIR) $@ +$(BUILD_PATH)/obj/: | $(BUILD_PATH)/ + $(MKDIR) $@ + +######################################################################################################################## + +clean: + $(RMRF) ./bin/ + cd ../ && $(MAKE) clean + +######################################################################################################################## + +modules: ../bin/debug/libcdsb.a + +../bin/debug/libcdsb.a: + cd ../ && $(MAKE) debug diff --git a/tests/src/array/main.c b/tests/src/array/main.c new file mode 100644 index 0000000..5c9f26c --- /dev/null +++ b/tests/src/array/main.c @@ -0,0 +1,8 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "plug.h" + +int main(int argc, char** argv) { + test_init(argc, argv); +} diff --git a/tests/src/array/plug.h b/tests/src/array/plug.h new file mode 100644 index 0000000..74bf6d4 --- /dev/null +++ b/tests/src/array/plug.h @@ -0,0 +1,29 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include +#include "../../../include/array.h" + +#include "../../include/random.h" +#include "../../include/test.h" +#include "../../include/time.h" + +vtype_string* string_duplicate(const vtype_string* x) { return 0; } +vtype_list* list_duplicate (const vtype_list* x) { return 0; } +vtype_map* map_duplicate (const vtype_map* x) { return 0; } +vtype_set* vset_duplicate (const vtype_set* x) { return 0; } + +void string_free(vtype_string* x) {} +void list_free (vtype_list* x) {} +void map_free (vtype_map* x) {} +void vset_free (vtype_set* x) {} + +int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } +int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } +int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } +int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } + +extern void string_copy_init(vtype_string* x, const vtype_string* s) { memset(x, 0, sizeof(*x)); } +extern void list_copy_init (vtype_list* x, const vtype_list* s) { memset(x, 0, sizeof(*x)); } +extern void map_copy_init (vtype_map* x, const vtype_map* s) { memset(x, 0, sizeof(*x)); } +extern void vset_copy_init (vtype_set* x, const vtype_set* s) { memset(x, 0, sizeof(*x)); } diff --git a/tests/src/list/main.c b/tests/src/list/main.c new file mode 100644 index 0000000..8fa9908 --- /dev/null +++ b/tests/src/list/main.c @@ -0,0 +1,13 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "plug.h" + +vtype_list* list_duplicate(const vtype_list* x) { return 0; } +int list_compare(const vtype_list* s0, const vtype_list* s1) { return random_int8(); } +void list_free(vtype_list* x) {} + + +int main(int argc, char** argv) { + test_init(argc, argv); +} diff --git a/tests/src/list/plug.h b/tests/src/list/plug.h new file mode 100644 index 0000000..76e2ed4 --- /dev/null +++ b/tests/src/list/plug.h @@ -0,0 +1,23 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../../include/list.h" + +#include "../../include/random.h" +#include "../../include/test.h" +#include "../../include/time.h" + +vtype_string* string_duplicate(const vtype_string* x) { return 0; } +vtype_array* array_duplicate (const vtype_array* x) { return 0; } +vtype_map* map_duplicate (const vtype_map* x) { return 0; } +vtype_set* vset_duplicate (const vtype_set* x) { return 0; } + +void string_free(vtype_string* x) {} +void array_free (vtype_array* x) {} +void map_free (vtype_map* x) {} +void vset_free (vtype_set* x) {} + +int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } +int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } +int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } +int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } diff --git a/tests/src/map/main.c b/tests/src/map/main.c new file mode 100644 index 0000000..a0638f1 --- /dev/null +++ b/tests/src/map/main.c @@ -0,0 +1,13 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "plug.h" + +vtype_map* map_duplicate(const vtype_map* x) { return 0; } +int map_compare(const vtype_map* s0, const vtype_map* s1) { return random_int8(); } +void map_free(vtype_map* x) {} + + +int main(int argc, char** argv) { + test_init(argc, argv); +} diff --git a/tests/src/map/plug.h b/tests/src/map/plug.h new file mode 100644 index 0000000..093107c --- /dev/null +++ b/tests/src/map/plug.h @@ -0,0 +1,23 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../../include/map.h" + +#include "../../include/random.h" +#include "../../include/test.h" +#include "../../include/time.h" + +vtype_string* string_duplicate(const vtype_string* x) { return 0; } +vtype_array* array_duplicate (const vtype_array* x) { return 0; } +vtype_list* list_duplicate (const vtype_list* x) { return 0; } +vtype_set* vset_duplicate (const vtype_set* x) { return 0; } + +void string_free(vtype_string* x) {} +void array_free (vtype_array* x) {} +void list_free (vtype_list* x) {} +void vset_free (vtype_set* x) {} + +int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } +int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } +int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } +int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } diff --git a/tests/src/set/main.c b/tests/src/set/main.c new file mode 100644 index 0000000..3ba1d93 --- /dev/null +++ b/tests/src/set/main.c @@ -0,0 +1,13 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "plug.h" + +vtype_set* vset_duplicate(const vtype_set* x) { return 0; } +int vset_compare(const vtype_set* s0, const vtype_set* s1) { return random_int8(); } +void vset_free(vtype_set* x) {} + + +int main(int argc, char** argv) { + test_init(argc, argv); +} diff --git a/tests/src/set/plug.h b/tests/src/set/plug.h new file mode 100644 index 0000000..661c878 --- /dev/null +++ b/tests/src/set/plug.h @@ -0,0 +1,23 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../../include/set.h" + +#include "../../include/random.h" +#include "../../include/test.h" +#include "../../include/time.h" + +vtype_string* string_duplicate(const vtype_string* x) { return 0; } +vtype_array* array_duplicate (const vtype_array* x) { return 0; } +vtype_list* list_duplicate (const vtype_list* x) { return 0; } +vtype_map* map_duplicate (const vtype_map* x) { return 0; } + +void string_free(vtype_string* x) {} +void array_free (vtype_array* x) {} +void list_free (vtype_list* x) {} +void map_free (vtype_map* x) {} + +int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } +int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } +int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } +int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } diff --git a/tests/src/string/main.c b/tests/src/string/main.c new file mode 100644 index 0000000..5c9f26c --- /dev/null +++ b/tests/src/string/main.c @@ -0,0 +1,8 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "plug.h" + +int main(int argc, char** argv) { + test_init(argc, argv); +} diff --git a/tests/src/string/plug.h b/tests/src/string/plug.h new file mode 100644 index 0000000..257d6e9 --- /dev/null +++ b/tests/src/string/plug.h @@ -0,0 +1,23 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../../include/extra/string.h" + +#include "../../include/random.h" +#include "../../include/test.h" +#include "../../include/time.h" + +vtype_array* array_duplicate (const vtype_array* x) { return 0; } +vtype_list* list_duplicate (const vtype_list* x) { return 0; } +vtype_map* map_duplicate (const vtype_map* x) { return 0; } +vtype_set* vset_duplicate (const vtype_set* x) { return 0; } + +void array_free (vtype_array* x) {} +void list_free (vtype_list* x) {} +void map_free (vtype_map* x) {} +void vset_free (vtype_set* x) {} + +int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } +int list_compare (const vtype_list* s0, const vtype_list* s1) { return random_int8(); } +int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } +int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); }