From 8d3576dbe0601513525006bdf87a2467e64116e7 Mon Sep 17 00:00:00 2001 From: Meleneth Date: Sat, 8 Jun 2024 07:41:10 +0000 Subject: [PATCH] Just googletest --- CMakeLists.txt | 12 +++++++++++- specs/CMakeLists.txt | 19 +++++++++++++++++++ specs/hello_spec.cpp | 10 ++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 specs/CMakeLists.txt create mode 100644 specs/hello_spec.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f167196..f69a31a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,15 @@ project( set(EXECUTABLE_NAME "QFO2Tool") add_executable(${EXECUTABLE_NAME}) +include(FetchContent) +FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip +) +# For Windows: Prevent overriding the parent project's compiler/linker settings +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +FetchContent_MakeAvailable(googletest) + # Windows compile stuff if (CMAKE_SYSTEM_NAME STREQUAL "Windows") @@ -62,6 +71,7 @@ include_directories(${SDL2_IMAGE_INCLUDE_DIRS}) #these are directories that have CMakeLists.txt files #are these used to determine how includes work? add_subdirectory(src/dependencies/GLAD SYSTEM) +add_subdirectory(specs) # add_subdirectory(src/dependencies/imgui-docking SYSTEM) add_subdirectory(src/dependencies/SDL_image SYSTEM) add_subdirectory(src/QFO2Tool SYSTEM) @@ -133,4 +143,4 @@ add_custom_command( ${CMAKE_CURRENT_SOURCE_DIR}/src/resources $/resources -) \ No newline at end of file +) diff --git a/specs/CMakeLists.txt b/specs/CMakeLists.txt new file mode 100644 index 0000000..8bbb761 --- /dev/null +++ b/specs/CMakeLists.txt @@ -0,0 +1,19 @@ +enable_testing() + +add_executable( + QFO2ToolLib_spec + hello_spec.cpp +) + +target_link_libraries( + QFO2ToolLib_spec PUBLIC + QFO2ToolLib + GTest::gtest_main +) + +target_include_directories(QFO2ToolLib_spec PUBLIC + ../src/QFO2ToolLib +) + +include(GoogleTest) +gtest_discover_tests(QFO2ToolLib_spec) diff --git a/specs/hello_spec.cpp b/specs/hello_spec.cpp new file mode 100644 index 0000000..9432d54 --- /dev/null +++ b/specs/hello_spec.cpp @@ -0,0 +1,10 @@ +#include + +// Demonstrate some basic assertions. +TEST(HelloTest, BasicAssertions) { + // Expect two strings not to be equal. + EXPECT_STRNE("hello", "world"); + // Expect equality. + EXPECT_EQ(7 * 6, 42); +} +