juk3n/fluffypublic Fork
⑂ 66a711a
Commits
⬇ Clone ▾
git clone https://git.rickub.com/juk3n/fluffy.git
git clone ssh://git@rickub.com/juk3n/fluffy.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Merge pull request #16 from Juk3n/15-add-test-frameworkUnverified

15 add test framework
Adrian Duraj committed 2024-07-02T13:56:13+02:00 Browse files
66a711a parents: 5584994 24b43d1
modified .gitignore +1 -1
@@ -1,3 +1,3 @@
11 *.vscode*
2-build/*
2+*/build/*
33 *sqlite*
\ No newline at end of file
@@ -1,3 +1,3 @@
1 *.vscode*1 *.vscode*
2-build/*2+*/build/*
3 *sqlite*3 *sqlite*
\ No newline at end of file\ No newline at end of file
renamed app/CMakeLists.txt +24 -5
similarity index 66%
rename from CMakeLists.txt
rename to app/CMakeLists.txt
@@ -17,25 +17,41 @@ if(NOT ftxui_POPULATED)
1717 endif()
1818
1919
20+FetchContent_Declare(googletest
21+ GIT_REPOSITORY https://github.com/google/googletest
22+ GIT_TAG v1.14.0
23+)
24+FetchContent_MakeAvailable(googletest)
25+
2026
21-find_program(CLANG_TIDY NAMES "clang-tidy" REQUIRED)
22-set(CLANG_TIDY_COMMAND "${CLANG_TIDY}" "-checks=-*,modernize-*")
27+#find_program(CLANG_TIDY NAMES "clang-tidy" REQUIRED)
28+#set(CLANG_TIDY_COMMAND "${CLANG_TIDY}" "-checks=-*,modernize-*")
2329
2430
2531 find_package(SQLite3 REQUIRED)
2632
2733 include_directories(${CMAKE_SOURCE_DIR}/include)
28-
34+enable_testing()
2935 add_executable(fluffy src/main.cpp)
3036
3137
38+
39+add_executable(
40+ tests
41+ tests/gameTest.cpp
42+)
43+target_link_libraries(
44+ tests
45+ GTest::gtest_main
46+)
47+
3248 target_link_libraries(fluffy
3349 PRIVATE ftxui::screen
3450 PRIVATE ftxui::dom
3551 PRIVATE ftxui::component
3652 PRIVATE SQLite::SQLite3
3753 )
38-set_target_properties(fluffy PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
54+#set_target_properties(fluffy PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
3955
4056 if (EMSCRIPTEN)
4157 string(APPEND CMAKE_CXX_FLAGS " -s USE_PTHREADS")
@@ -45,4 +61,7 @@ if (EMSCRIPTEN)
4561 foreach(file "index.html" "run_webassembly.py")
4662 configure_file("src/${file}" ${file})
4763 endforeach(file)
48-endif()
\ No newline at end of file
64+endif()
65+
66+include(GoogleTest)
67+gtest_discover_tests(tests)
similarity index 66%
rename from CMakeLists.txt
rename to app/CMakeLists.txt
@@ -17,25 +17,41 @@ if(NOT ftxui_POPULATED)
17 endif()17 endif()
18 18
19 19
20+FetchContent_Declare(googletest
21+ GIT_REPOSITORY https://github.com/google/googletest
22+ GIT_TAG v1.14.0
23+)
24+FetchContent_MakeAvailable(googletest)
25+
20 26
21-find_program(CLANG_TIDY NAMES "clang-tidy" REQUIRED)27+#find_program(CLANG_TIDY NAMES "clang-tidy" REQUIRED)
22-set(CLANG_TIDY_COMMAND "${CLANG_TIDY}" "-checks=-*,modernize-*")28+#set(CLANG_TIDY_COMMAND "${CLANG_TIDY}" "-checks=-*,modernize-*")
23 29
24 30
25 find_package(SQLite3 REQUIRED)31 find_package(SQLite3 REQUIRED)
26 32
27 include_directories(${CMAKE_SOURCE_DIR}/include)33 include_directories(${CMAKE_SOURCE_DIR}/include)
28-34+enable_testing()
29 add_executable(fluffy src/main.cpp)35 add_executable(fluffy src/main.cpp)
30 36
31 37
38+
39+add_executable(
40+ tests
41+ tests/gameTest.cpp
42+)
43+target_link_libraries(
44+ tests
45+ GTest::gtest_main
46+)
47+
32 target_link_libraries(fluffy48 target_link_libraries(fluffy
33 PRIVATE ftxui::screen49 PRIVATE ftxui::screen
34 PRIVATE ftxui::dom50 PRIVATE ftxui::dom
35 PRIVATE ftxui::component51 PRIVATE ftxui::component
36 PRIVATE SQLite::SQLite352 PRIVATE SQLite::SQLite3
37 )53 )
38-set_target_properties(fluffy PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")54+#set_target_properties(fluffy PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
39 55
40 if (EMSCRIPTEN) 56 if (EMSCRIPTEN)
41 string(APPEND CMAKE_CXX_FLAGS " -s USE_PTHREADS") 57 string(APPEND CMAKE_CXX_FLAGS " -s USE_PTHREADS")
@@ -45,4 +61,7 @@ if (EMSCRIPTEN)
45 foreach(file "index.html" "run_webassembly.py")61 foreach(file "index.html" "run_webassembly.py")
46 configure_file("src/${file}" ${file})62 configure_file("src/${file}" ${file})
47 endforeach(file)63 endforeach(file)
48-endif()
\ No newline at end of file\ No newline at end of file
64+endif()
65+
66+include(GoogleTest)
67+gtest_discover_tests(tests)
renamed app/include/game.hpp +0 -0
similarity index 100%
rename from include/game.hpp
rename to app/include/game.hpp
similarity index 100%
rename from include/game.hpp
rename to app/include/game.hpp
renamed app/src/main.cpp +0 -0
similarity index 100%
rename from src/main.cpp
rename to app/src/main.cpp
similarity index 100%
rename from src/main.cpp
rename to app/src/main.cpp
added app/tests/gameTest.cpp +11 -0
new file mode 100644
@@ -0,0 +1,11 @@
1+#include <gtest/gtest.h>
2+
3+#include <game.hpp>
4+
5+TEST(GameTest, Creation) {
6+ Game sut{0, "sut", "sut/path"};
7+
8+ EXPECT_EQ(0, sut.getId());
9+ EXPECT_EQ("sut", sut.getName());
10+ EXPECT_EQ("sut/path", sut.getPath());
11+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,11 @@
1+#include <gtest/gtest.h>
2+
3+#include <game.hpp>
4+
5+TEST(GameTest, Creation) {
6+ Game sut{0, "sut", "sut/path"};
7+
8+ EXPECT_EQ(0, sut.getId());
9+ EXPECT_EQ("sut", sut.getName());
10+ EXPECT_EQ("sut/path", sut.getPath());
11+}
\ No newline at end of file\ No newline at end of file