1
0
forked from Alepha/Alepha

Boolean test lambdas can now be used properly.

This commit is contained in:
2022-10-16 01:36:13 -04:00
parent deeb27cb9f
commit e170f3f172

View File

@ -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