123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #define CATCH_CONFIG_MAIN
- #define CATCH_CONFIG_RUNTIME_STATIC_REQUIRE
- #include <catch2/catch.hpp>
- #include <type_traits>
- #include <stdexcept>
- [[noreturn]]
- void this_throws() {
- throw std::runtime_error("Some msg");
- }
- void this_doesnt_throw() {}
- CATCH_TEST_CASE("PrefixedMacros") {
- using namespace Catch::Matchers;
- CATCH_REQUIRE( 1 == 1 );
- CATCH_REQUIRE_FALSE( 1 != 1 );
- CATCH_REQUIRE_THROWS(this_throws());
- CATCH_REQUIRE_THROWS_AS(this_throws(), std::runtime_error);
- CATCH_REQUIRE_THROWS_WITH(this_throws(), "Some msg");
- CATCH_REQUIRE_THROWS_MATCHES(this_throws(), std::runtime_error, Predicate<std::runtime_error>([](std::runtime_error const&) { return true; }));
- CATCH_REQUIRE_NOTHROW(this_doesnt_throw());
- CATCH_CHECK( 1 == 1 );
- CATCH_CHECK_FALSE( 1 != 1 );
- CATCH_CHECKED_IF( 1 == 1 ) {
- CATCH_SUCCEED("don't care");
- } CATCH_CHECKED_ELSE ( 1 == 1 ) {
- CATCH_SUCCEED("don't care");
- }
- CATCH_CHECK_NOFAIL(1 == 2);
- CATCH_CHECK_THROWS(this_throws());
- CATCH_CHECK_THROWS_AS(this_throws(), std::runtime_error);
- CATCH_CHECK_THROWS_WITH(this_throws(), "Some msg");
- CATCH_CHECK_THROWS_MATCHES(this_throws(), std::runtime_error, Predicate<std::runtime_error>([](std::runtime_error const&) { return true; }));
- CATCH_CHECK_NOTHROW(this_doesnt_throw());
- CATCH_REQUIRE_THAT("abcd", Equals("abcd"));
- CATCH_CHECK_THAT("bdef", Equals("bdef"));
- CATCH_INFO( "some info" );
- CATCH_UNSCOPED_INFO( "some info" );
- CATCH_WARN( "some warn" );
- CATCH_SECTION("some section") {
- int i = 1;
- CATCH_CAPTURE( i );
- CATCH_DYNAMIC_SECTION("Dynamic section: " << i) {
- CATCH_FAIL_CHECK( "failure" );
- }
- }
- CATCH_STATIC_REQUIRE( std::is_void<void>::value );
- CATCH_STATIC_REQUIRE_FALSE( std::is_void<int>::value );
- }
- CATCH_ANON_TEST_CASE() {
- CATCH_FAIL("");
- }
|