forked from catchorg/Catch2
Add extra test binary & test for CATCH_CONFIG_FAST_COMPILE
Closes #3100
This commit is contained in:
@@ -526,6 +526,19 @@ set_tests_properties(TestSpecs::SkippingAllTestsFails
|
||||
WILL_FAIL ON
|
||||
)
|
||||
|
||||
add_executable(FastCompileMacros ${TESTS_DIR}/X07-FastCompileMacros.cpp)
|
||||
target_link_libraries(FastCompileMacros PRIVATE Catch2_buildall_interface)
|
||||
target_compile_definitions(FastCompileMacros PRIVATE CATCH_CONFIG_FAST_COMPILE)
|
||||
|
||||
add_test(
|
||||
NAME CompileConfiguration::FastCompile
|
||||
COMMAND $<TARGET_FILE:FastCompileMacros>
|
||||
)
|
||||
set_tests_properties(CompileConfiguration::FastCompile
|
||||
PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION "test cases: 6 \\| 1 passed \\| 1 failed \\| 4 failed as expected\nassertions: 13 \\| 6 passed \\| 2 failed \\| 5 failed as expected"
|
||||
)
|
||||
|
||||
# This sets up a one-off executable that compiles against the amalgamated
|
||||
# files, and then runs it for a super simple check that the amalgamated
|
||||
# files are usable.
|
||||
@@ -595,6 +608,7 @@ set(EXTRA_TEST_BINARIES
|
||||
NoTests
|
||||
ListenersGetEventsBeforeReporters
|
||||
MixingClearedAndUnclearedMessages
|
||||
FastCompileMacros
|
||||
InfiniteGenerators
|
||||
ThreadSafetyTests
|
||||
# DebugBreakMacros
|
||||
|
||||
@@ -3,7 +3,6 @@ yet:
|
||||
|
||||
CATCH_CONFIG_COUNTER // Use __COUNTER__ to generate unique names for test cases
|
||||
CATCH_CONFIG_WINDOWS_SEH // Enable SEH handling on Windows
|
||||
CATCH_CONFIG_FAST_COMPILE // Sacrifices some (rather minor) features for compilation speed
|
||||
CATCH_CONFIG_POSIX_SIGNALS // Enable handling POSIX signals
|
||||
CATCH_CONFIG_WINDOWS_CRTDBG // Enable leak checking using Windows's CRT Debug Heap
|
||||
CATCH_CONFIG_DEFAULT_REPORTER
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
/**\file
|
||||
* Test that various basic macros work with CATCH_CONFIG_FAST_COMPILE.
|
||||
*
|
||||
* Note that the current checking is rather loose. We check that the
|
||||
* macros compile, and that the test cases (don't) fail as they are
|
||||
* supposed to.
|
||||
*/
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace {
|
||||
|
||||
[[noreturn]]
|
||||
static void throws() {
|
||||
throw std::runtime_error{ "sup" };
|
||||
}
|
||||
static void doesnt_throw() {}
|
||||
[[noreturn]]
|
||||
static int throws_i() {
|
||||
throw std::runtime_error{ "sup" };
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_CASE( "Passing macros work" ) {
|
||||
REQUIRE( 1 != 2 );
|
||||
CHECK( 2 == 2 );
|
||||
REQUIRE_THROWS( throws() );
|
||||
REQUIRE_NOTHROW( doesnt_throw() );
|
||||
}
|
||||
|
||||
TEST_CASE( "Failing macros work", "[!shouldfail]" ) {
|
||||
CHECK( 1 != 2 );
|
||||
CHECK( 2 == 2 );
|
||||
CHECK( 3 == 2 );
|
||||
}
|
||||
|
||||
TEST_CASE( "Failing NOTHROW works", "[!shouldfail]" ) {
|
||||
REQUIRE_NOTHROW( throws() );
|
||||
}
|
||||
|
||||
TEST_CASE( "Failing THROW works", "[!shouldfail]" ) {
|
||||
REQUIRE_THROWS( doesnt_throw() );
|
||||
}
|
||||
|
||||
TEST_CASE( "Unexpected exception in REQUIRE gets inverted properly",
|
||||
"[!shouldfail]" ) {
|
||||
REQUIRE( throws_i() == 1 );
|
||||
}
|
||||
|
||||
TEST_CASE( "Unexpected exception in REQUIRE fails properly" ) {
|
||||
REQUIRE( throws_i() == 2 );
|
||||
}
|
||||
Reference in New Issue
Block a user