From b954870e45eba557ab460fc0efac8cc76a9fa3d0 Mon Sep 17 00:00:00 2001 From: Mineplay Date: Sat, 12 Apr 2025 15:10:26 -0500 Subject: [PATCH] refactor(tests): moved main.c to seperate tests folder --- CMakeLists.txt | 11 +++++---- Src/{Hallocy => }/Allocator.c | 2 +- Src/Main.c | 23 ------------------ Tests/Main.c | 44 +++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 29 deletions(-) rename Src/{Hallocy => }/Allocator.c (99%) delete mode 100644 Src/Main.c create mode 100644 Tests/Main.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 321f2de..499bee9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,21 +5,22 @@ set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) include_directories(${PROJECT_SOURCE_DIR}/Include) -file(GLOB_RECURSE SRC_FILES "${PROJECT_SOURCE_DIR}/Src/Hallocy/*.c") +file(GLOB_RECURSE SRC_FILES "${PROJECT_SOURCE_DIR}/Src/*.c") add_library(Hallocy STATIC ${SRC_FILES}) -add_executable(HallocyApp ${PROJECT_SOURCE_DIR}/Src/Main.c) +add_executable(HallocyTest ${PROJECT_SOURCE_DIR}/Tests/Main.c) -target_link_libraries(HallocyApp Hallocy) +target_include_directories(HallocyTest PRIVATE ${PROJECT_SOURCE_DIR}/Tests) +target_link_libraries(HallocyTest Hallocy) if (MSVC) target_compile_options(Hallocy PRIVATE /W4 /Zl) else() target_compile_options(Hallocy PRIVATE -mavx512f -mavx512vl) - target_compile_options(HallocyApp PRIVATE -mavx512f -mavx512vl) + target_compile_options(HallocyTest PRIVATE -mavx512f -mavx512vl) target_compile_options(Hallocy PRIVATE -march=native) - target_compile_options(HallocyApp PRIVATE -march=native) + target_compile_options(HallocyTest PRIVATE -march=native) target_compile_options(Hallocy PRIVATE -Wall -Wextra -pedantic) endif() \ No newline at end of file diff --git a/Src/Hallocy/Allocator.c b/Src/Allocator.c similarity index 99% rename from Src/Hallocy/Allocator.c rename to Src/Allocator.c index 6ecf751..5471122 100644 --- a/Src/Hallocy/Allocator.c +++ b/Src/Allocator.c @@ -20,7 +20,7 @@ * Author: Mineplay * ----------------------------------------------------------------------------- */ -#include "../../Include/Hallocy/Allocator.h" +#include "../Include/Hallocy/Allocator.h" #if defined(_WIN32) #include diff --git a/Src/Main.c b/Src/Main.c deleted file mode 100644 index 8fc9e75..0000000 --- a/Src/Main.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -int main() { - char *memory = (char *)hallocy_malloc(12288); - if (memory == NULL) { - printf("Failed it allocate memory!"); - return -1; - } - - memory[0] = 'H'; - memory[1] = 'i'; - memory[2] = '\0'; - - printf("%s\n", memory); - int code = hallocy_free(memory); - if (code != HALLOCY_ERROR_NONE) { - printf("Failed to free memory error code (%d)!", code); - return -1; - } - - return 0; -} \ No newline at end of file diff --git a/Tests/Main.c b/Tests/Main.c new file mode 100644 index 0000000..3b13990 --- /dev/null +++ b/Tests/Main.c @@ -0,0 +1,44 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ----------------------------------------------------------------------------- + * File: Main.c + * Description: + * Executes all tests. + * + * Author: Mineplay + * ----------------------------------------------------------------------------- + */ + #include + #include + + int main() { + char *memory = (char *)hallocy_malloc(12288); + if (memory == NULL) { + printf("Failed it allocate memory!"); + return -1; + } + + memory[0] = 'H'; + memory[1] = 'i'; + memory[2] = '\0'; + + printf("%s\n", memory); + int code = hallocy_free(memory); + if (code != HALLOCY_ERROR_NONE) { + printf("Failed to free memory error code (%d)!", code); + return -1; + } + + return 0; + } \ No newline at end of file