File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed
Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ set(CMAKE_AUTORCC ON)
99set (CMAKE_CXX_STANDARD 17)
1010set (CMAKE_CXX_STANDARD_REQUIRED ON )
1111
12+ option (SCRATCHCPPGUI_BUILD_UNIT_TESTS "Build unit tests" ON )
13+
1214include (build /FindQt.cmake)
1315
1416qt_standard_project_setup(REQUIRES 6.6)
@@ -26,3 +28,8 @@ target_link_libraries(libscratchcpp-gui PRIVATE scratchcpp)
2628add_subdirectory (thirdparty/libqnanopainter)
2729target_include_directories (libscratchcpp-gui PRIVATE thirdparty/libqnanopainter)
2830target_link_libraries (libscratchcpp-gui PRIVATE qnanopainter)
31+
32+ if (SCRATCHCPPGUI_BUILD_UNIT_TESTS)
33+ enable_testing ()
34+ add_subdirectory (test )
35+ endif ()
Original file line number Diff line number Diff line change 1+ cmake_minimum_required (VERSION 3.14)
2+ project (libscratchcpp_test)
3+
4+ set (CMAKE_CXX_STANDARD 17)
5+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
6+ add_compile_definitions (DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR} " )
7+
8+ set (GTEST_DIR thirdparty/googletest)
9+ add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /../${GTEST_DIR} ${CMAKE_CURRENT_BINARY_DIR} /${GTEST_DIR} )
10+
11+ # For Windows: Prevent overriding the parent project's compiler/linker settings
12+ set (gtest_force_shared_crt ON CACHE BOOL "" FORCE)
13+
14+ include (GoogleTest)
15+
16+ function (add_test TARGET )
17+ target_include_directories (${TARGET} PRIVATE ${CMAKE_SOURCE_DIR} /ScratchCPPGui)
18+ endfunction ()
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include < gtest/gtest.h>
4+ #include < filesystem>
5+ #include < fstream>
6+
7+ int main (int argc, char **argv)
8+ {
9+ std::filesystem::current_path (DATA_DIR);
10+ ::testing::InitGoogleTest (&argc, argv);
11+ return RUN_ALL_TESTS ();
12+ }
You can’t perform that action at this time.
0 commit comments