From 6b3492636a18f87192fc46f4bc7bc02a0e399fc9 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Thu, 26 Oct 2023 00:38:05 -0400 Subject: [PATCH] Make test exception not part of the hierarchy. (It shouldn't be caught, but for the framework. Although `Condition` may be the right type?) --- Testing/test.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Testing/test.h b/Testing/test.h index 1e0076e..ff29d31 100644 --- a/Testing/test.h +++ b/Testing/test.h @@ -60,7 +60,7 @@ namespace Alepha::Hydrogen::Testing namespace exports { - struct TestFailureException; + struct TestFailure; inline namespace literals { @@ -89,11 +89,13 @@ namespace Alepha::Hydrogen::Testing return rv; }; - struct exports::TestFailureException + struct exports::TestFailure { int failureCount= -1; + std::string message_; - explicit TestFailureException( const int failureCount ) : failureCount( failureCount ) {} + explicit TestFailure( const int failureCount ) + : failureCount( failureCount ) {} }; template< Integral Integer > @@ -106,7 +108,7 @@ namespace Alepha::Hydrogen::Testing { if( not test() ) { - throw TestFailureException{ 1 }; + throw TestFailure{ 1 }; } }; @@ -117,7 +119,7 @@ namespace Alepha::Hydrogen::Testing auto wrapper= [test] { const int failures= test(); - if( failures > 0 ) throw TestFailureException{ failures }; + if( failures > 0 ) throw TestFailure{ failures }; }; return name <= wrapper; @@ -141,7 +143,7 @@ namespace Alepha::Hydrogen::Testing void demand( const bool state, const std::string test= "" ) { - if( not state ) throw TestFailureException( failures.size() + 1 ); + if( not state ) throw TestFailure( failures.size() + 1 ); } }; @@ -211,7 +213,7 @@ namespace Alepha::Hydrogen::Testing std::cout << " " << C::testFail << "FAILURE" << resetStyle << ": " << name; throw; } - catch( const TestFailureException &fail ) { std::cout << " -- " << fail.failureCount << " failures."; } + catch( const TestFailure &fail ) { std::cout << " -- " << fail.failureCount << " failures."; } catch( ... ) { std::cout << " -- unknown failure count"; } std::cout << std::endl; }