From c9f7e9cbc3a9e3a1288ed1a0aade892cf949ee83 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 11 Nov 2023 11:01:03 -0500 Subject: [PATCH] This can be the type erased base for Table Test. --- Testing/TableTest.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) 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 {