mirror of
https://github.com/catchorg/Catch2.git
synced 2025-01-16 07:08:01 +00:00
Compare commits
4 Commits
33c58dad41
...
26622f1620
Author | SHA1 | Date | |
---|---|---|---|
|
26622f1620 | ||
|
c086746cc9 | ||
|
0c223bb751 | ||
|
19ecad6f68 |
@ -2,9 +2,9 @@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||
pkg_version=@Catch2_VERSION@
|
||||
|
||||
Name: Catch2-Main
|
||||
Description: Links in the default main function for Catch2
|
||||
Name: Catch2-With-Main
|
||||
Description: A modern, C++-native test framework for C++14 and above (links in default main)
|
||||
Version: ${pkg_version}
|
||||
Requires: catch2 = ${pkg_version}
|
||||
Cflags: -I${includedir}
|
||||
Libs: -L${libdir} -lCatch2Main
|
||||
Libs: -L${libdir} -lCatch2WithMain
|
@ -2,7 +2,7 @@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||
|
||||
Name: Catch2
|
||||
Description: A modern, C++-native, header-only, test framework for C++14 and above
|
||||
Description: A modern, C++-native, test framework for C++14 and above
|
||||
URL: https://github.com/catchorg/Catch2
|
||||
Version: @Catch2_VERSION@
|
||||
Cflags: -I${includedir}
|
||||
|
@ -166,14 +166,14 @@ if (NOT_SUBPROJECT)
|
||||
@ONLY
|
||||
)
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMake/catch2-main.pc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/catch2-main.pc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMake/catch2-with-main.pc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/catch2-with-main.pc
|
||||
@ONLY
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/catch2.pc"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/catch2-main.pc"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/catch2-with-main.pc"
|
||||
DESTINATION
|
||||
${PKGCONFIG_INSTALL_DIR}
|
||||
)
|
||||
|
@ -52,7 +52,7 @@ set(ALL_EXAMPLE_TARGETS
|
||||
)
|
||||
|
||||
foreach( name ${ALL_EXAMPLE_TARGETS} )
|
||||
target_link_libraries( ${name} Catch2 Catch2Main )
|
||||
target_link_libraries( ${name} Catch2 Catch2WithMain )
|
||||
set_property(TARGET ${name} PROPERTY CXX_STANDARD 14)
|
||||
set_property(TARGET ${name} PROPERTY CXX_EXTENSIONS OFF)
|
||||
endforeach()
|
||||
|
@ -269,19 +269,22 @@ target_include_directories(Catch2
|
||||
)
|
||||
|
||||
|
||||
add_library(Catch2Main STATIC
|
||||
add_library(Catch2WithMain STATIC
|
||||
${SOURCES_DIR}/internal/catch_main.cpp
|
||||
)
|
||||
add_library(Catch2::Catch2Main ALIAS Catch2Main)
|
||||
target_link_libraries(Catch2Main PUBLIC Catch2)
|
||||
|
||||
add_library(Catch2::Catch2WithMain ALIAS Catch2WithMain)
|
||||
target_link_libraries(Catch2WithMain PUBLIC Catch2)
|
||||
set_target_properties(Catch2WithMain
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "Catch2Main"
|
||||
)
|
||||
|
||||
if (NOT_SUBPROJECT)
|
||||
# create and install an export set for catch target as Catch2::Catch
|
||||
install(
|
||||
TARGETS
|
||||
Catch2
|
||||
Catch2Main
|
||||
Catch2WithMain
|
||||
EXPORT
|
||||
Catch2Targets
|
||||
DESTINATION
|
||||
@ -342,5 +345,5 @@ if (CATCH_BUILD_EXAMPLES OR CATCH_BUILD_EXTRA_TESTS)
|
||||
)
|
||||
endif()
|
||||
|
||||
list(APPEND CATCH_WARNING_TARGETS Catch2 Catch2Main)
|
||||
list(APPEND CATCH_WARNING_TARGETS Catch2 Catch2WithMain)
|
||||
set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE)
|
||||
|
@ -15,7 +15,7 @@ add_executable(PrefixedMacros ${TESTS_DIR}/X01-PrefixedMacros.cpp)
|
||||
target_compile_definitions( PrefixedMacros PRIVATE CATCH_CONFIG_PREFIX_ALL CATCH_CONFIG_RUNTIME_STATIC_REQUIRE )
|
||||
# Macro configuration does not touch the compiled parts, so we can link
|
||||
# it against the main library
|
||||
target_link_libraries( PrefixedMacros Catch2 )
|
||||
target_link_libraries( PrefixedMacros Catch2WithMain )
|
||||
|
||||
add_test(NAME CATCH_CONFIG_PREFIX_ALL COMMAND PrefixedMacros -s)
|
||||
set_tests_properties(
|
||||
@ -33,7 +33,7 @@ add_executable(DisabledMacros ${TESTS_DIR}/X02-DisabledMacros.cpp)
|
||||
target_compile_definitions( DisabledMacros PRIVATE CATCH_CONFIG_DISABLE )
|
||||
# Macro configuration does not touch the compiled parts, so we can link
|
||||
# it against the main library
|
||||
target_link_libraries( DisabledMacros Catch2 )
|
||||
target_link_libraries( DisabledMacros Catch2WithMain )
|
||||
|
||||
add_test(NAME CATCH_CONFIG_DISABLE-1 COMMAND DisabledMacros -s)
|
||||
set_tests_properties(
|
||||
@ -97,7 +97,7 @@ set_tests_properties(
|
||||
|
||||
add_executable(FallbackStringifier ${TESTS_DIR}/X10-FallbackStringifier.cpp)
|
||||
target_compile_definitions( FallbackStringifier PRIVATE CATCH_CONFIG_FALLBACK_STRINGIFIER=fallbackStringifier )
|
||||
target_link_libraries( FallbackStringifier Catch2 )
|
||||
target_link_libraries( FallbackStringifier Catch2WithMain )
|
||||
|
||||
add_test(NAME FallbackStringifier COMMAND FallbackStringifier -r compact -s)
|
||||
set_tests_properties(
|
||||
@ -109,7 +109,7 @@ set_tests_properties(
|
||||
|
||||
add_executable(DisableStringification ${TESTS_DIR}/X11-DisableStringification.cpp)
|
||||
target_compile_definitions( DisableStringification PRIVATE CATCH_CONFIG_DISABLE_STRINGIFICATION )
|
||||
target_link_libraries(DisableStringification Catch2)
|
||||
target_link_libraries(DisableStringification Catch2WithMain)
|
||||
add_test(NAME CATCH_CONFIG_DISABLE_STRINGIFICATION COMMAND DisableStringification -r compact -s)
|
||||
set_tests_properties(
|
||||
CATCH_CONFIG_DISABLE_STRINGIFICATION
|
||||
@ -126,7 +126,7 @@ if (MSVC)
|
||||
set_property( TARGET WindowsHeader PROPERTY CXX_STANDARD 14 )
|
||||
set_property( TARGET WindowsHeader PROPERTY CXX_STANDARD_REQUIRED ON )
|
||||
set_property( TARGET WindowsHeader PROPERTY CXX_EXTENSIONS OFF )
|
||||
target_link_libraries( WindowsHeader Catch2 )
|
||||
target_link_libraries( WindowsHeader Catch2WithMain )
|
||||
add_test(NAME WindowsHeader COMMAND WindowsHeader -r compact)
|
||||
list(APPEND CATCH_WARNING_TARGETS ${EXTRA_TEST_BINARIES} WindowsHeader)
|
||||
endif()
|
||||
|
@ -1,9 +1,8 @@
|
||||
// X11-DisableStringification.cpp
|
||||
// X01-DisableStringification.cpp
|
||||
// Test that Catch's prefixed macros compile and run properly.
|
||||
|
||||
#include <catch2/internal/catch_default_main.hpp>
|
||||
// This won't provide full coverage, but it might be worth checking
|
||||
// the other branch as well
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/matchers/catch_matchers_predicate.hpp>
|
||||
#include <catch2/matchers/catch_matchers_string.hpp>
|
||||
|
@ -2,7 +2,6 @@
|
||||
// Test that CATCH_CONFIG_DISABLE turns off TEST_CASE autoregistration
|
||||
// and expressions in assertion macros are not run.
|
||||
|
||||
#include <catch2/internal/catch_default_main.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
@ -9,7 +9,6 @@ std::string fallbackStringifier(T const&) {
|
||||
return "{ !!! }";
|
||||
}
|
||||
|
||||
#include <catch2/internal/catch_default_main.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
struct foo {
|
||||
|
@ -4,7 +4,6 @@
|
||||
// and preprocessor token pasting. In other words, hopefully this test
|
||||
// will be deleted soon :-)
|
||||
|
||||
#include <catch2/internal/catch_default_main.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
namespace {
|
||||
|
@ -4,7 +4,6 @@
|
||||
// wrong.
|
||||
|
||||
#include <windows.h>
|
||||
#include <catch2/internal/catch_default_main.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE("Catch2 did survive compilation with windows.h", "[compile-test]") {
|
||||
|
@ -341,8 +341,9 @@ TEST_CASE("Multiple random generators in one test case output different values",
|
||||
same += random1.get() == random2.get();
|
||||
random1.next(); random2.next();
|
||||
}
|
||||
// 0.5% seems like a sane bound for random identical elements within 1000 runs
|
||||
REQUIRE(same < 5);
|
||||
// Because the previous low bound failed CI couple of times,
|
||||
// we use a very high threshold of 20% before failure is reported.
|
||||
REQUIRE(same < 200);
|
||||
}
|
||||
SECTION("Float") {
|
||||
auto random1 = Catch::Generators::random(0., 1000.);
|
||||
@ -352,7 +353,8 @@ TEST_CASE("Multiple random generators in one test case output different values",
|
||||
same += random1.get() == random2.get();
|
||||
random1.next(); random2.next();
|
||||
}
|
||||
// 0.5% seems like a sane bound for random identical elements within 1000 runs
|
||||
REQUIRE(same < 5);
|
||||
// Because the previous low bound failed CI couple of times,
|
||||
// we use a very high threshold of 20% before failure is reported.
|
||||
REQUIRE(same < 200);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user