From e170f3f172957b23a12f0894848119272ab4f12b Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 16 Oct 2022 01:36:13 -0400 Subject: [PATCH] Boolean test lambdas can now be used properly. --- Testing/test.h | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Testing/test.h b/Testing/test.h index e7fe23a..7d19b6d 100644 --- a/Testing/test.h +++ b/Testing/test.h @@ -97,13 +97,28 @@ namespace Alepha::Hydrogen::Testing inline auto operator <= ( TestName name, std::function< Integer () > test ) { - auto wrapper= [test] + if constexpr( std::is_same_v< Integer, bool > ) { - const int failures= test(); - if( failures > 0 ) throw TestFailureException{ failures }; - }; + auto wrapper= [test] + { + if( not test ) + { + throw TestFailureException{ 1 }; + } + }; - return name <= wrapper; + return name <= wrapper; + } + else + { + auto wrapper= [test] + { + const int failures= test(); + if( failures > 0 ) throw TestFailureException{ failures }; + }; + + return name <= wrapper; + } } namespace exports