1
0
forked from Alepha/Alepha

Individual TableTest cases can be disabled.

This commit is contained in:
2023-11-13 11:45:56 -05:00
parent 4682fe3ffb
commit c6b66aa7b5
5 changed files with 92 additions and 17 deletions

View File

@ -39,7 +39,7 @@ namespace Alepha::Hydrogen::Testing ::detail:: TableTest_m
namespace C:: inline Colors
{
using namespace testing_colors::C::Colors;
using namespace testing_colors::C:: Colors;
}
enum class TestResult { Passed, Failed };
@ -304,6 +304,65 @@ namespace Alepha::Hydrogen::Testing ::detail:: TableTest_m
int operator() () const;
};
struct CaseComment
{
enum State : bool { Enabled= true, Disabled= false } state= Enabled;
std::string comment;
CaseComment( const Concepts::ConvertibleTo< std::string > auto &comment )
: comment( comment ) {}
explicit
CaseComment( const State state, const std::string &comment )
: state( state ), comment( comment ) {}
auto
operator not () const
{
return CaseComment{ State( not state ), comment };
}
auto
operator -() const
{
return CaseComment{ State( not state ), comment };
}
};
namespace exports
{
inline namespace literals
{
inline CaseComment
operator ""_case ( const char *const ch, const std::size_t amt )
{
return CaseComment{ std::string{ ch, ch + amt } };
}
}
enum { Enable= 1, Skip= -1, Disable= -1 };
inline auto
operator - ( const decltype( Enable ) e )
{
return decltype( Enable )( -int( e ) );
}
inline auto
operator not ( const decltype( Enable ) e )
{
return e == Enable ? Enable : Disable;
}
inline auto
operator <= ( const decltype( Enable ) token, const CaseComment &comment )
{
if( token == Disable ) return CaseComment{ CaseComment::Disabled, comment.comment };
else return CaseComment{ CaseComment::Enabled, comment.comment };
}
}
template< FunctionVariable auto function, OutputMode outputMode >
struct exports::TableTest
{
@ -323,7 +382,7 @@ namespace Alepha::Hydrogen::Testing ::detail:: TableTest_m
struct TestDescription
{
std::string comment;
CaseComment comment;
args_type args;
UniversalHandler handler;
};
@ -343,7 +402,18 @@ namespace Alepha::Hydrogen::Testing ::detail:: TableTest_m
{
return handler( invoker, comment );
};
tests.tests.push_back( { comment, checker } );
if( comment.state == CaseComment::Enabled )
{
tests.tests.push_back( { comment.comment, checker } );
}
else
{
auto skippedHandler= [] ( const auto comment ) -> std::tuple< TestResult, std::optional< std::string > >
{
return { TestResult::Passed, "Skipped." };
};
tests.tests.push_back( { comment.comment, skippedHandler } );
}
}
}
@ -364,3 +434,8 @@ namespace Alepha::Hydrogen::Testing::inline exports::inline TableTest_m
{
using namespace detail::TableTest_m::exports;
}
namespace Alepha::Hydrogen::Testing::inline exports::inline literals::inline test_literals
{
using namespace detail::TableTest_m::exports::literals;
}