diff --git a/Testing/TableTest.h b/Testing/TableTest.h index 704a9db..d37ad6a 100644 --- a/Testing/TableTest.h +++ b/Testing/TableTest.h @@ -258,6 +258,51 @@ namespace Alepha::Hydrogen::Testing ::detail:: table_test return rv; } + struct UniversalCasesBase + { + using TestFunction_t= std::tuple< TestResult, std::optional< std::string > > ( const std::string & ); + using TestFunction= std::function< TestFunction_t >; + struct TestRunner + { + std::string comment; + TestFunction handler; + }; + std::vector< TestRunner > tests; + + virtual ~UniversalCasesBase()= default; + + int + operator() () const + { + int failureCount= 0; + for( const auto &[ comment, checker ]: tests ) + { + const auto [result, supplement]= checker( comment ); + if( result == TestResult::Failed ) + { + ++failureCount; + std::cout << " " << C::testFail << "FAILED CASE" << resetStyle << ": " << comment << std::endl; + if( supplement.has_value() ) + { + std::cout << " " << C::testWarn << "DETAILS" << resetStyle << ": " << supplement.value() << std::endl; + } + } + else + { + std::cout << " " << C::testPass << "PASSED CASE" << resetStyle << ": " << comment << std::endl; + if( supplement.has_value() ) + { + std::cout << " " << C::testWarn << "INFO: " << resetStyle << ": " << supplement.value() << std::endl; + } + } + breakpoint(); + } + + return failureCount; + } + + }; + template< FunctionVariable auto function, OutputMode outputMode > struct exports::TableTest {