diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2f3694f..0ebabd4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,3 +17,5 @@ jobs: run: cmake . - name: Build run: cmake --build . + - name: Run all the tests + run: ctest \ No newline at end of file diff --git a/.gitignore b/.gitignore index d92facb..9069764 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ build/ .DS_Store .vscode + +Testing/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 82bbd53..f4f1461 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,3 +15,6 @@ target_include_directories(x86 PUBLIC ${SDL2_INCLUDE_DIRS} ) target_include_directories(x86 PRIVATE include SDL2) + +include(CTest) +add_subdirectory(test) diff --git a/test.sh b/test.sh deleted file mode 100755 index 0589dd5..0000000 --- a/test.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -make clean -make x86_test -./x86_test \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..3e4e9ad --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.26.0) + +project(x86_tests) + +include(FetchContent) +FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip +) + +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +FetchContent_MakeAvailable(googletest) + +add_executable(memory_tests ${CMAKE_SOURCE_DIR}/src/Memory.cpp ${CMAKE_SOURCE_DIR}/src/Object.cpp MemoryTests.cpp) +target_link_libraries(memory_tests GTest::gtest_main) +target_include_directories(memory_tests PRIVATE ../include) +add_test(NAME memory_tests COMMAND memory_tests WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/tests/Memory/test.cpp b/test/MemoryTests.cpp similarity index 98% rename from tests/Memory/test.cpp rename to test/MemoryTests.cpp index 92480e9..80e91e9 100644 --- a/tests/Memory/test.cpp +++ b/test/MemoryTests.cpp @@ -1,5 +1,5 @@ -#include "../../include/Memory.h" -#include "../../include/Cpu.h" +#include "Memory.h" +#include "Cpu.h" #include #include using namespace std; diff --git a/tests/Memory/Makefile b/tests/Memory/Makefile deleted file mode 100644 index 6c1a334..0000000 --- a/tests/Memory/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -.PHONY:clean build all test - -CC = clang++ - -G++_OPTIONS = -Wall -std=c++14 -O0 -g -I $(INCLUDE_DIR) -DDEBUG -arch x86_64 -LD_FLGS += -lSDL2 -lgtest_main -lgtest -arch x86_64 - - -SOURCE_DIR = ../../src/ -INCLUDE_DIR = ../../include/ -DETAIL_INCLUDE_DIR = ../../include/detail/ - -HEADERS = $(wildcard $(INCLUDE_DIR)*.h) -DETAIL_HEADERS = $(wildcard $(DETAIL_INCLUDE_DIR)*.h) - -test_memory : test.o test_memory.o - $(CC) $(LD_FLGS) -o test_memory $^ - -test.o : test.cpp $(HEADERS) $(DETAIL_HEADERS) - $(CC) $(G++_OPTIONS) -o $@ -c $< - -test_memory.o : $(SOURCE_DIR)Memory.cpp $(HEADERS) $(DETAIL_HEADERS) - $(CC) $(G++_OPTIONS) -o $@ -c $< - -clean: - rm *.o \ No newline at end of file diff --git a/tests/Memory/test_memory b/tests/Memory/test_memory deleted file mode 100755 index d7b58a1..0000000 Binary files a/tests/Memory/test_memory and /dev/null differ