Skip to content

Commit

Permalink
Use Catch2 v3 for unit tests
Browse files Browse the repository at this point in the history
Fixes #133
  • Loading branch information
dimztimz committed Nov 7, 2023
1 parent f98c7c4 commit 8ee9ed4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 27 deletions.
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,30 @@ macro(fetch_catch2)
include(FetchContent)
FetchContent_Declare(Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG 62fd660583d3ae7a7886930b413c3c570e89786c #v2.13.9
GIT_TAG 3f0283de7a9c43200033da996ff9093be3ac84dc #v3.3.2
)
FetchContent_GetProperties(Catch2)
if(NOT catch2_POPULATED)
FetchContent_Populate(Catch2)
set(old_build_shared_libs ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(${catch2_SOURCE_DIR} ${catch2_BINARY_DIR})
target_compile_features(Catch2 PRIVATE cxx_std_17)
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/contrib)
set(BUILD_SHARED_LIBS ${old_build_shared_libs})
endif()
endmacro()

if (BUILD_TESTING)
enable_testing()
find_package(Catch2 2.3.0 QUIET)
find_package(Catch2 3.1.1 QUIET)
if (NOT Catch2_FOUND)
fetch_catch2()
endif()
add_subdirectory(external/hunspell/hunspell)
add_subdirectory(tests)
endif()


configure_file(nuspell.pc.in nuspell.pc @ONLY)
#configure_file(NuspellConfig.cmake NuspellConfig.cmake COPYONLY)
write_basic_package_version_file(NuspellConfigVersion.cmake
Expand Down
4 changes: 2 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_executable(unit_test unit_test.cxx catch_main.cxx)
target_link_libraries(unit_test PRIVATE nuspell Catch2::Catch2)
add_executable(unit_test unit_test.cxx)
target_link_libraries(unit_test PRIVATE nuspell Catch2::Catch2WithMain)
if (MSVC)
target_compile_options(unit_test PRIVATE "/utf-8")
# Consider doing this for all the other targets by setting this flag
Expand Down
20 changes: 0 additions & 20 deletions tests/catch_main.cxx

This file was deleted.

3 changes: 2 additions & 1 deletion tests/unit_test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* along with Nuspell. If not, see <http://www.gnu.org/licenses/>.
*/

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <nuspell/dictionary.hxx>
#include <nuspell/utils.hxx>

Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"dependencies": [
{
"name": "catch2",
"version>=": "2.13.9"
"version>=": "3.3.2"
},
{
"name": "getopt",
Expand Down

0 comments on commit 8ee9ed4

Please sign in to comment.