diff options
| author | Martin Hořeňovský | 2021-06-20 16:25:57 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2021-06-20 19:15:02 +0200 |
| commit | bf61a418cbc4d3b430e3d258c5287780944ad505 (patch) | |
| tree | f93f4136d7b2a14cc4fdecc8a90ad9415ead4c17 /tests/SelfTest/UsageTests/Exception.tests.cpp | |
| parent | 849002aec0271b0a8356162134ea78731e84454a (diff) | |
| download | catch3-bf61a418cbc4d3b430e3d258c5287780944ad505.tar.gz | |
Remove the ill-conceived compilation perf tests using real tests
Diffstat (limited to 'tests/SelfTest/UsageTests/Exception.tests.cpp')
| -rw-r--r-- | tests/SelfTest/UsageTests/Exception.tests.cpp | 71 |
1 files changed, 32 insertions, 39 deletions
diff --git a/tests/SelfTest/UsageTests/Exception.tests.cpp b/tests/SelfTest/UsageTests/Exception.tests.cpp index 1f6b4fa2..206bd9c8 100644 --- a/tests/SelfTest/UsageTests/Exception.tests.cpp +++ b/tests/SelfTest/UsageTests/Exception.tests.cpp @@ -20,55 +20,50 @@ #pragma clang diagnostic ignored "-Wunreachable-code" #endif -namespace { namespace ExceptionTests { +namespace { -#ifndef EXCEPTION_TEST_HELPERS_INCLUDED // Don't compile this more than once per TU -#define EXCEPTION_TEST_HELPERS_INCLUDED + int thisThrows() { + throw std::domain_error("expected exception"); + return 1; + } -int thisThrows() { - throw std::domain_error( "expected exception" ); - return 1; -} + int thisDoesntThrow() { + return 0; + } -int thisDoesntThrow() { - return 0; -} + class CustomException { + public: + explicit CustomException(const std::string& msg) + : m_msg(msg) {} -class CustomException { -public: - explicit CustomException( const std::string& msg ) - : m_msg( msg ) - {} + std::string getMessage() const { + return m_msg; + } - std::string getMessage() const { - return m_msg; - } + private: + std::string m_msg; + }; -private: - std::string m_msg; -}; + class CustomStdException : public std::exception { + public: + explicit CustomStdException(const std::string& msg) + : m_msg(msg) {} + ~CustomStdException() noexcept override {} -class CustomStdException : public std::exception { -public: - explicit CustomStdException( const std::string& msg ) - : m_msg( msg ) - {} - ~CustomStdException() noexcept override {} + std::string getMessage() const { + return m_msg; + } - std::string getMessage() const { - return m_msg; - } + private: + std::string m_msg; + }; -private: - std::string m_msg; -}; + [[noreturn]] void throwCustom() { + throw CustomException("custom exception - not std"); + } -[[noreturn]] void throwCustom() { - throw CustomException( "custom exception - not std" ); } -#endif - TEST_CASE( "When checked exceptions are thrown they can be expected or unexpected", "[!throws]" ) { REQUIRE_THROWS_AS( thisThrows(), std::domain_error ); REQUIRE_NOTHROW( thisDoesntThrow() ); @@ -198,8 +193,6 @@ TEST_CASE( "#748 - captures with unexpected exceptions", "[.][failing][!throws][ } } -}} // namespace ExceptionTests - #ifdef __clang__ #pragma clang diagnostic pop #endif |