diff --git a/App/CMakeLists.txt b/App/CMakeLists.txt index 305ae4a..6075892 100644 --- a/App/CMakeLists.txt +++ b/App/CMakeLists.txt @@ -5,4 +5,5 @@ project ("App") enable_testing() add_subdirectory(App) -add_subdirectory(AppLib) \ No newline at end of file +add_subdirectory(AppLib) +add_subdirectory(Tests) \ No newline at end of file diff --git a/App/Tests/CMakeLists.txt b/App/Tests/CMakeLists.txt index 6cd755f..2bf25c5 100644 --- a/App/Tests/CMakeLists.txt +++ b/App/Tests/CMakeLists.txt @@ -1,25 +1,21 @@ cmake_minimum_required (VERSION 3.8) -# Add source to this project's executable. - -file(GLOB SRCS "src/*.cpp") -file(GLOB_RECURSE HDRS "include/*.hh") - - -add_library(AppLib - ${SRCS} - ${HDRS} -) - -target_include_directories(AppLib PUBLIC "${CMAKE_SOURCE_DIR}/AppLib/include/AppLib") - enable_testing() +add_executable( + AppTest + MathTest.cpp +) + find_package(GTest CONFIG REQUIRED) target_link_libraries(AppTest PRIVATE GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main) -add_test(AllTestsInMain AppTest) if (CMAKE_VERSION VERSION_GREATER 3.12) set_property(TARGET AppLib PROPERTY CXX_STANDARD 20) endif() + +include(GoogleTest) +gtest_discover_tests(AppTest) + +add_test(MathTest AppTest) \ No newline at end of file diff --git a/App/Tests/MathTest.cpp b/App/Tests/MathTest.cpp new file mode 100644 index 0000000..3af7f38 --- /dev/null +++ b/App/Tests/MathTest.cpp @@ -0,0 +1,16 @@ +#include + +// Demonstrate some basic assertions. +TEST(AppTest, BasicAssertions) { + // Expect two strings not to be equal. + EXPECT_STRNE("hello", "world"); + // Expect equality. + EXPECT_EQ(7 * 6, 42); +} + + +int main(int argc, char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} \ No newline at end of file