diff --git a/Testing/TableTest.h b/Testing/TableTest.h index 26a3e4f..b956b1e 100644 --- a/Testing/TableTest.h +++ b/Testing/TableTest.h @@ -165,8 +165,9 @@ namespace Alepha::Hydrogen::Testing ::detail:: TableTest_m } {} + template< typename ... Params > std::tuple< TestResult, std::optional< std::string > > - operator() ( Invoker invoker, const std::string &comment ) const + operator() ( Invoker invoker, const std::string &comment, const std::tuple< Params... > params ) const { if( impl != nullptr ) return impl( invoker, comment ); if constexpr( std::is_base_of_v< std::decay_t< return_type >, ComputedBase > ) @@ -202,6 +203,14 @@ namespace Alepha::Hydrogen::Testing ::detail:: TableTest_m streamDebugging< outputMode >( oss, std::get< return_type >( witness ), expected ); } else oss << "Unexpected exception of type: " << std::get< ErrorMessage >( witness ).mesg; + + oss << std::endl << "Test inputs were: " << std::endl; + int index= 0; + tuple_for_each( params ) <=[&]( const auto ¶m ) + { + // Debugging output for test inputs is relaxed, as it's not required they be streamable? + oss << "Argument " << index++ << ": " << streamAdaptValue< OutputMode::Relaxed >( param ) << std::endl; + }; } return { result, oss.str().empty() ? std::optional< std::string >{} : std::move( oss ).str() }; } @@ -472,7 +481,7 @@ namespace Alepha::Hydrogen::Testing ::detail:: TableTest_m }; const auto checker= [=]( const auto comment ) { - return handler( invoker, comment ); + return handler( invoker, comment, params ); }; if( comment.state == CaseComment::Enabled ) { diff --git a/Testing/printDebugging.h b/Testing/printDebugging.h index 1dd12e2..7e0229f 100644 --- a/Testing/printDebugging.h +++ b/Testing/printDebugging.h @@ -39,6 +39,9 @@ namespace Alepha::Hydrogen::Testing ::detail:: printDebugging_m template< OutputMode outputMode, typename T > void printDebugging( const T &witness, const T &expected ); + + template< OutputMode outputMode, typename T > + auto streamAdaptValue( const T &v ); } using namespace std::literals::string_literals; @@ -124,7 +127,11 @@ namespace Alepha::Hydrogen::Testing ::detail:: printDebugging_m } else { - static_assert( dependent_value< false, T >, "One of the types used in the testing table does not support stringification." ); + if constexpr( outputMode == OutputMode::Relaxed ) + { + oss << ""; + } + else static_assert( dependent_value< false, T >, "One of the types used in the testing table does not support stringification." ); } } @@ -143,7 +150,7 @@ namespace Alepha::Hydrogen::Testing ::detail:: printDebugging_m template< OutputMode outputMode, typename T > auto - streamAdaptValue( const T &v ) + exports::streamAdaptValue( const T &v ) { return Adaptor< outputMode, std::decay_t< T > >{ v }; }