added sample test
399709b parent: 5584994 modified
CMakeLists.txt +24 -2 | @@ -17,6 +17,12 @@ if(NOT ftxui_POPULATED) | ||
| 17 | 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 | 27 | find_program(CLANG_TIDY NAMES "clang-tidy" REQUIRED) |
| 22 | 28 | set(CLANG_TIDY_COMMAND "${CLANG_TIDY}" "-checks=-*,modernize-*") |
| @@ -25,10 +31,20 @@ set(CLANG_TIDY_COMMAND "${CLANG_TIDY}" "-checks=-*,modernize-*") | ||
| 25 | 31 | find_package(SQLite3 REQUIRED) |
| 26 | 32 | |
| 27 | 33 | include_directories(${CMAKE_SOURCE_DIR}/include) |
| 28 | - | |
| 34 | +enable_testing() | |
| 29 | 35 | add_executable(fluffy src/main.cpp) |
| 30 | 36 | |
| 31 | 37 | |
| 38 | + | |
| 39 | +add_executable( | |
| 40 | + hello_test | |
| 41 | + tests/tests.cc | |
| 42 | +) | |
| 43 | +target_link_libraries( | |
| 44 | + hello_test | |
| 45 | + GTest::gtest_main | |
| 46 | +) | |
| 47 | + | |
| 32 | 48 | target_link_libraries(fluffy |
| 33 | 49 | PRIVATE ftxui::screen |
| 34 | 50 | PRIVATE ftxui::dom |
| @@ -45,4 +61,10 @@ if (EMSCRIPTEN) | ||
| 45 | 61 | foreach(file "index.html" "run_webassembly.py") |
| 46 | 62 | configure_file("src/${file}" ${file}) |
| 47 | 63 | endforeach(file) |
| 48 | -endif() | |
| \ No newline at end of file | ||
| 64 | +endif() | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | +include(GoogleTest) | |
| 70 | +gtest_discover_tests(hello_test) | |
| @@ -17,6 +17,12 @@ 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-*") |
| @@ -25,10 +31,20 @@ set(CLANG_TIDY_COMMAND "${CLANG_TIDY}" "-checks=-*,modernize-*") | |||
| 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 | + hello_test | ||
| 41 | + tests/tests.cc | ||
| 42 | +) | ||
| 43 | +target_link_libraries( | ||
| 44 | + hello_test | ||
| 45 | + GTest::gtest_main | ||
| 46 | +) | ||
| 47 | + | ||
| 32 | target_link_libraries(fluffy | 48 | target_link_libraries(fluffy |
| 33 | PRIVATE ftxui::screen | 49 | PRIVATE ftxui::screen |
| 34 | PRIVATE ftxui::dom | 50 | PRIVATE ftxui::dom |
| @@ -45,4 +61,10 @@ 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 | + | ||
| 67 | + | ||
| 68 | + | ||
| 69 | +include(GoogleTest) | ||
| 70 | +gtest_discover_tests(hello_test) | ||
added
tests/tests.cc +9 -0 | new file mode 100644 | ||
| @@ -0,0 +1,9 @@ | ||
| 1 | +#include <gtest/gtest.h> | |
| 2 | + | |
| 3 | +// Demonstrate some basic assertions. | |
| 4 | +TEST(HelloTest, BasicAssertions) { | |
| 5 | + // Expect two strings not to be equal. | |
| 6 | + EXPECT_STRNE("hello", "world"); | |
| 7 | + // Expect equality. | |
| 8 | + EXPECT_EQ(7 * 6, 42); | |
| 9 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | +#include <gtest/gtest.h> | ||
| 2 | + | ||
| 3 | +// Demonstrate some basic assertions. | ||
| 4 | +TEST(HelloTest, BasicAssertions) { | ||
| 5 | + // Expect two strings not to be equal. | ||
| 6 | + EXPECT_STRNE("hello", "world"); | ||
| 7 | + // Expect equality. | ||
| 8 | + EXPECT_EQ(7 * 6, 42); | ||
| 9 | +} | ||