Skip to content

Commit

Permalink
update Catch2 from v2.13.4 to v3.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
herzbube committed Dec 31, 2023
1 parent ba17c73 commit 96cff50
Show file tree
Hide file tree
Showing 32 changed files with 114 additions and 72 deletions.
2 changes: 1 addition & 1 deletion test/AssertHelperFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <SgfcUtility.h>

// Unit test library includes
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

namespace LibSgfcPlusPlus
{
Expand Down
46 changes: 45 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,46 @@ if ( NOT DEFINED SOURCES )
message ( FATAL_ERROR "List of source files not defined by ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCES_LIST_FILE_NAME}" )
endif()

# Define a number of variables for working with the Catch2 library
set ( CATCH2_LIBRARY_BASE_NAME Catch2 )
set ( CATCH2_PACKAGE_NAME ${CATCH2_LIBRARY_BASE_NAME} )
set ( CATCH2_PACKAGE_FOUND_VARIABLE_NAME ${CATCH2_PACKAGE_NAME}_FOUND )
set ( CATCH2_LINK_LIBRARY_TARGET_NAME Catch2::Catch2WithMain )

# Attempt to find the Catch2 package, first as a system-wide package, then
# if that fails as a sub-directory in a custom location. The default is to look
# in the Catch2 Git submodule, but the user can override this.
find_package (
${CATCH2_PACKAGE_NAME}
3
QUIET)
if ( ${${CATCH2_PACKAGE_FOUND_VARIABLE_NAME}} )
message ( STATUS "Found system-wide Catch2 CMake package." )
message ( STATUS "${CATCH2_PACKAGE_FOUND_VARIABLE_NAME} = ${${CATCH2_PACKAGE_FOUND_VARIABLE_NAME}}" )
else()
message ( STATUS "System-wide Catch2 CMake package not found." )

if ( NOT DEFINED CATCH2_GITREPOSITORY_PREFIX )
message ( STATUS "Using default git repository prefix to find Catch2 CMake package." )
message ( STATUS "Define CATCH2_GITREPOSITORY_PREFIX to override this." )
# A well known path: The Catch2 Git submodule.
set ( CATCH2_GITREPOSITORY_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/Catch2" )
else()
message ( STATUS "Using user-provided git repository prefix to find Catch2 CMake package." )
endif()

# Here we expect to find the Catch2 source distribution, either as Catch2 git
# repository clone or as a plain directory that is structurally identical to
# the repository layout. In this form Catch2 supports easy integration via
# add_subdirectory. The advantage over find_package() is that the user does
# not need to build/install the Catch2 library separately - Catch2 is simply
# built as part of the test project without the need of installation.
message ( STATUS "Adding Catch2 CMake package as sub-directory from ${CATCH2_GITREPOSITORY_PREFIX}." )
add_subdirectory (
${CATCH2_GITREPOSITORY_PREFIX}
)
endif()

# See src/CMakeLists.txt for the explanation why we disable this compiler
# warning.
if ( ${MSVC} )
Expand All @@ -26,9 +66,11 @@ add_executable (
# below. Reason: The target_link_libraries statement is also a dependency
# declaration that causes CMake to add all PUBLIC include directories of the
# dependency target to our own target.
# The same is true for the directory that contains the Catch2 header files:
# This directory is also added because we add Catch2 in the
# target_link_libraries statement below.
target_include_directories (
${TEST_EXECUTABLE_TARGET_NAME}
PRIVATE Catch2/single_include
# The tests treat libsgfc++ itself as a third-party library, so the next two
# include directories are required to find the public interface headers and
# the private implementation headers.
Expand All @@ -42,7 +84,9 @@ target_include_directories (
# necessary symbols visible on all platforms.
target_link_libraries (
${TEST_EXECUTABLE_TARGET_NAME}
PRIVATE
${LINK_LIBRARY_TARGET_NAME}
${CATCH2_LINK_LIBRARY_TARGET_NAME}
)

# Define additional compile options.
Expand Down
2 changes: 1 addition & 1 deletion test/Catch2
Submodule Catch2 updated 743 files
1 change: 0 additions & 1 deletion test/SourcesList.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
set (
SOURCES
main.cpp
document/SgfcDocumentTest.cpp
document/SgfcGameTest.cpp
document/SgfcNodeTest.cpp
Expand Down
2 changes: 1 addition & 1 deletion test/document/SgfcDocumentTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern "C"
}

// Unit test library includes
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

// C++ Standard Library includes
#include <cstring> // needed for strlen
Expand Down
3 changes: 2 additions & 1 deletion test/document/SgfcGameTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
#include <SgfcUtility.h>

// Unit test library includes
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators_all.hpp>

using namespace LibSgfcPlusPlus;

Expand Down
3 changes: 2 additions & 1 deletion test/document/SgfcNodeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
#include <SgfcUtility.h>

// Unit test library includes
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators_range.hpp>

using namespace LibSgfcPlusPlus;

Expand Down
2 changes: 1 addition & 1 deletion test/document/SgfcNodeTraitsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <SgfcNodeTraits.h>

// Unit test library includes
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

// C++ Standard Library includes
#include <cmath> // for pow()
Expand Down
2 changes: 1 addition & 1 deletion test/document/SgfcTreeBuilderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <document/SgfcNode.h>

// Unit test library includes
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

using namespace LibSgfcPlusPlus;

Expand Down
11 changes: 6 additions & 5 deletions test/game/SgfcDateTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include <SgfcDate.h>

// Unit test library includes
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators_range.hpp>

using namespace LibSgfcPlusPlus;

Expand Down Expand Up @@ -118,7 +119,7 @@ SCENARIO( "An SgfcPropertyType::DT property value is decomposed", "[game]" )
{
GIVEN( "The property value is valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetValidPropertyValuesDT()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetValidPropertyValuesDT()) );

WHEN( "The property value is decomposed" )
{
Expand All @@ -142,7 +143,7 @@ SCENARIO( "An SgfcPropertyType::DT property value is decomposed", "[game]" )

GIVEN( "The property value is not valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetInvalidPropertyValuesDT()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetInvalidPropertyValuesDT()) );

WHEN( "The property value is decomposed" )
{
Expand All @@ -160,7 +161,7 @@ SCENARIO( "An SgfcPropertyType::DT property value is composed", "[game]" )
{
GIVEN( "The SgfcDate objects are valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetValidSgfcDates()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetValidSgfcDates()) );

WHEN( "The property value is composed" )
{
Expand All @@ -176,7 +177,7 @@ SCENARIO( "An SgfcPropertyType::DT property value is composed", "[game]" )

GIVEN( "The SgfcDate objects are not valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetInvalidSgfcDates()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetInvalidSgfcDates()) );

WHEN( "The property value is composed" )
{
Expand Down
11 changes: 6 additions & 5 deletions test/game/SgfcGameResultTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include <SgfcGameResult.h>

// Unit test library includes
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators_range.hpp>

using namespace LibSgfcPlusPlus;

Expand Down Expand Up @@ -74,7 +75,7 @@ SCENARIO( "An SgfcPropertyType::RE property value is decomposed", "[game]" )
{
GIVEN( "The property value is valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetValidPropertyValuesRE()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetValidPropertyValuesRE()) );

WHEN( "The property value is decomposed" )
{
Expand All @@ -91,7 +92,7 @@ SCENARIO( "An SgfcPropertyType::RE property value is decomposed", "[game]" )

GIVEN( "The property value is not valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetInvalidPropertyValuesRE()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetInvalidPropertyValuesRE()) );

WHEN( "The property value is decomposed" )
{
Expand All @@ -109,7 +110,7 @@ SCENARIO( "An SgfcPropertyType::RE property value is composed", "[game]" )
{
GIVEN( "The SgfcGameResult object is valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetValidSgfcGameResults()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetValidSgfcGameResults()) );

WHEN( "The property value is composed" )
{
Expand All @@ -125,7 +126,7 @@ SCENARIO( "An SgfcPropertyType::RE property value is composed", "[game]" )

GIVEN( "The SgfcGameResult object is not valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetInvalidSgfcGameResults()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetInvalidSgfcGameResults()) );

WHEN( "The property value is composed" )
{
Expand Down
11 changes: 6 additions & 5 deletions test/game/SgfcRoundInformationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include <SgfcRoundInformation.h>

// Unit test library includes
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators_range.hpp>

using namespace LibSgfcPlusPlus;

Expand Down Expand Up @@ -73,7 +74,7 @@ SCENARIO( "An SgfcPropertyType::RO property value is decomposed", "[game]" )
{
GIVEN( "The property value is valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetValidPropertyValuesRO()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetValidPropertyValuesRO()) );

WHEN( "The property value is decomposed" )
{
Expand All @@ -90,7 +91,7 @@ SCENARIO( "An SgfcPropertyType::RO property value is decomposed", "[game]" )

GIVEN( "The property value is not valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetInvalidPropertyValuesRO()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetInvalidPropertyValuesRO()) );

WHEN( "The property value is decomposed" )
{
Expand All @@ -108,7 +109,7 @@ SCENARIO( "An SgfcPropertyType::RO property value is composed", "[game]" )
{
GIVEN( "The SgfcRoundInformation object is valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetValidSgfcRoundInformations()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetValidSgfcRoundInformations()) );

WHEN( "The property value is composed" )
{
Expand All @@ -124,7 +125,7 @@ SCENARIO( "An SgfcPropertyType::RO property value is composed", "[game]" )

GIVEN( "The SgfcRoundInformation object is not valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetInvalidSgfcRoundInformations()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetInvalidSgfcRoundInformations()) );

WHEN( "The property value is composed" )
{
Expand Down
3 changes: 2 additions & 1 deletion test/game/go/SgfcGoMoveTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#include <SgfcConstants.h>

// Unit test library includes
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators_range.hpp>

using namespace LibSgfcPlusPlus;

Expand Down
11 changes: 6 additions & 5 deletions test/game/go/SgfcGoPlayerRankTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include <SgfcGoPlayerRank.h>

// Unit test library includes
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators_range.hpp>

using namespace LibSgfcPlusPlus;

Expand Down Expand Up @@ -74,7 +75,7 @@ SCENARIO( "An SgfcPropertyType::BR or SgfcPropertyType::WR property value is dec
{
GIVEN( "The property value is valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetValidPropertyValuesBRWR()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetValidPropertyValuesBRWR()) );

WHEN( "The property value is decomposed" )
{
Expand All @@ -91,7 +92,7 @@ SCENARIO( "An SgfcPropertyType::BR or SgfcPropertyType::WR property value is dec

GIVEN( "The property value is not valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetInvalidPropertyValuesBRWR()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetInvalidPropertyValuesBRWR()) );

WHEN( "The property value is decomposed" )
{
Expand All @@ -109,7 +110,7 @@ SCENARIO( "An SgfcPropertyType::BR or SgfcPropertyType::WR property value is com
{
GIVEN( "The SgfcGoPlayerRank object is valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetValidSgfcGoPlayerRanks()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetValidSgfcGoPlayerRanks()) );

WHEN( "The property value is composed" )
{
Expand All @@ -125,7 +126,7 @@ SCENARIO( "An SgfcPropertyType::BR or SgfcPropertyType::WR property value is com

GIVEN( "The SgfcGoPlayerRank object is not valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetInvalidSgfcGoPlayerRanks()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetInvalidSgfcGoPlayerRanks()) );

WHEN( "The property value is composed" )
{
Expand Down
3 changes: 2 additions & 1 deletion test/game/go/SgfcGoPointTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include <SgfcUtility.h>

// Unit test library includes
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators_range.hpp>

using namespace LibSgfcPlusPlus;

Expand Down
11 changes: 6 additions & 5 deletions test/game/go/SgfcGoRulesetTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include <SgfcGoRuleset.h>

// Unit test library includes
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators_range.hpp>

using namespace LibSgfcPlusPlus;

Expand Down Expand Up @@ -72,7 +73,7 @@ SCENARIO( "An SgfcPropertyType::RU property value is decomposed", "[game]" )
{
GIVEN( "The property value is valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetValidPropertyValuesRU()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetValidPropertyValuesRU()) );

WHEN( "The property value is decomposed" )
{
Expand All @@ -89,7 +90,7 @@ SCENARIO( "An SgfcPropertyType::RU property value is decomposed", "[game]" )

GIVEN( "The property value is not valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetInvalidPropertyValuesRU()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetInvalidPropertyValuesRU()) );

WHEN( "The property value is decomposed" )
{
Expand All @@ -107,7 +108,7 @@ SCENARIO( "An SgfcPropertyType::RU property value is composed", "[game]" )
{
GIVEN( "The SgfcGoRuleset object is valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetValidSgfcGoRulesets()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetValidSgfcGoRulesets()) );

WHEN( "The property value is composed" )
{
Expand All @@ -123,7 +124,7 @@ SCENARIO( "An SgfcPropertyType::RU property value is composed", "[game]" )

GIVEN( "The SgfcGoRuleset object is not valid" )
{
auto& testData = GENERATE( from_range(TestDataGenerator::GetInvalidSgfcGoRulesets()) );
auto testData = GENERATE( from_range(TestDataGenerator::GetInvalidSgfcGoRulesets()) );

WHEN( "The property value is composed" )
{
Expand Down
3 changes: 2 additions & 1 deletion test/game/go/SgfcGoStoneTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include <SgfcConstants.h>

// Unit test library includes
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators_range.hpp>

using namespace LibSgfcPlusPlus;

Expand Down
Loading

0 comments on commit 96cff50

Please sign in to comment.