Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests/SelfTest/UsageTests/Exception.tests.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-06-20 16:25:57 +0200
committerMartin Hořeňovský2021-06-20 19:15:02 +0200
commitbf61a418cbc4d3b430e3d258c5287780944ad505 (patch)
treef93f4136d7b2a14cc4fdecc8a90ad9415ead4c17 /tests/SelfTest/UsageTests/Exception.tests.cpp
parent849002aec0271b0a8356162134ea78731e84454a (diff)
downloadcatch3-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.cpp71
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