refactor(tests): moved main.c to seperate tests folder

This commit is contained in:
Mineplay 2025-04-12 15:10:26 -05:00
parent 21e79b8af4
commit b954870e45
4 changed files with 51 additions and 29 deletions

View file

@ -5,21 +5,22 @@ set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD_REQUIRED ON)
include_directories(${PROJECT_SOURCE_DIR}/Include) 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_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) if (MSVC)
target_compile_options(Hallocy PRIVATE /W4 /Zl) target_compile_options(Hallocy PRIVATE /W4 /Zl)
else() else()
target_compile_options(Hallocy PRIVATE -mavx512f -mavx512vl) 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(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) target_compile_options(Hallocy PRIVATE -Wall -Wextra -pedantic)
endif() endif()

View file

@ -20,7 +20,7 @@
* Author: Mineplay * Author: Mineplay
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
*/ */
#include "../../Include/Hallocy/Allocator.h" #include "../Include/Hallocy/Allocator.h"
#if defined(_WIN32) #if defined(_WIN32)
#include <windows.h> #include <windows.h>

View file

@ -1,23 +0,0 @@
#include <stdio.h>
#include <Hallocy/Allocator.h>
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;
}

44
Tests/Main.c Normal file
View file

@ -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 <stdio.h>
#include <Hallocy/Allocator.h>
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;
}