Add working test example to app
This commit is contained in:
parent
b6f00051ed
commit
7434dd80a7
@ -5,4 +5,5 @@ project ("App")
|
|||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
add_subdirectory(App)
|
add_subdirectory(App)
|
||||||
add_subdirectory(AppLib)
|
add_subdirectory(AppLib)
|
||||||
|
add_subdirectory(Tests)
|
||||||
@ -1,25 +1,21 @@
|
|||||||
cmake_minimum_required (VERSION 3.8)
|
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()
|
enable_testing()
|
||||||
|
|
||||||
|
add_executable(
|
||||||
|
AppTest
|
||||||
|
MathTest.cpp
|
||||||
|
)
|
||||||
|
|
||||||
find_package(GTest CONFIG REQUIRED)
|
find_package(GTest CONFIG REQUIRED)
|
||||||
target_link_libraries(AppTest PRIVATE GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)
|
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)
|
if (CMAKE_VERSION VERSION_GREATER 3.12)
|
||||||
set_property(TARGET AppLib PROPERTY CXX_STANDARD 20)
|
set_property(TARGET AppLib PROPERTY CXX_STANDARD 20)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include(GoogleTest)
|
||||||
|
gtest_discover_tests(AppTest)
|
||||||
|
|
||||||
|
add_test(MathTest AppTest)
|
||||||
16
App/Tests/MathTest.cpp
Normal file
16
App/Tests/MathTest.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user