externals: Update catch2 to v3.5.0

Merge commit 'ba06a404d1'
This commit is contained in:
Yang Liu 2023-12-31 14:00:46 +08:00
commit b372dc6157
272 changed files with 22238 additions and 7949 deletions

View file

@ -261,6 +261,10 @@ TEST_CASE("Copy and then generate a range", "[generators]") {
}
}
#if defined( __clang__ )
# pragma clang diagnostic pop
#endif
TEST_CASE("#1913 - GENERATE inside a for loop should not keep recreating the generator", "[regression][generators]") {
static int counter = 0;
for (int i = 0; i < 3; ++i) {
@ -277,6 +281,43 @@ TEST_CASE("#1913 - GENERATEs can share a line", "[regression][generators]") {
REQUIRE(i != j);
}
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
namespace {
class test_generator : public Catch::Generators::IGenerator<int> {
public:
[[noreturn]] explicit test_generator() {
// removing the following line will cause the program to terminate
// gracefully.
throw Catch::GeneratorException( "failure to init" );
}
auto get() const -> int const& override {
static constexpr int value = 1;
return value;
}
auto next() -> bool override { return false; }
};
static auto make_test_generator()
-> Catch::Generators::GeneratorWrapper<int> {
return { new test_generator() };
}
} // namespace
TEST_CASE( "#2615 - Throwing in constructor generator fails test case but does not abort",
"[!shouldfail][regression][generators]" ) {
// this should fail the test case, but not abort the application
auto sample = GENERATE( make_test_generator() );
// this assertion shouldn't trigger
REQUIRE( sample == 0 );
}
TEST_CASE( "GENERATE can combine literals and generators", "[generators]" ) {
auto i = GENERATE( 2,
4,
take( 2,
filter( []( int val ) { return val % 2 == 0; },
random( -100, 100 ) ) ) );
REQUIRE( i % 2 == 0 );
}