forked from Alepha/Alepha
Testing improvements.
This commit is contained in:
@ -15,9 +15,6 @@ static_assert( __cplusplus > 2020'99 );
|
||||
#include <numeric>
|
||||
#include <iomanip>
|
||||
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <Alepha/function_traits.h>
|
||||
#include <Alepha/template_for_each.h>
|
||||
|
||||
@ -25,6 +22,7 @@ static_assert( __cplusplus > 2020'99 );
|
||||
|
||||
#include <Alepha/Utility/evaluation_helpers.h>
|
||||
#include <Alepha/Utility/TupleAdapter.h>
|
||||
#include <Alepha/Utility/fancyTypeName.h>
|
||||
|
||||
#include <Alepha/Reflection/tuplizeAggregate.h>
|
||||
|
||||
@ -84,7 +82,7 @@ namespace Alepha::Hydrogen::Testing ::detail:: TableTest_m
|
||||
}
|
||||
catch( const std::exception &ex )
|
||||
{
|
||||
return ErrorMessage{ typeid( ex ).name() };
|
||||
return ErrorMessage{ Utility::fancyTypeName( typeid( ex ) ) };
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
@ -127,7 +125,7 @@ namespace Alepha::Hydrogen::Testing ::detail:: TableTest_m
|
||||
}
|
||||
catch( const std::exception &ex )
|
||||
{
|
||||
return ErrorMessage{ typeid( ex ).name() };
|
||||
return ErrorMessage{ Utility::fancyTypeName( typeid( ex ) ) };
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
@ -160,13 +158,26 @@ namespace Alepha::Hydrogen::Testing ::detail:: TableTest_m
|
||||
{
|
||||
try
|
||||
{
|
||||
std::ignore= invoker();
|
||||
breakpoint();
|
||||
return { TestResult::Failed, std::nullopt };
|
||||
try
|
||||
{
|
||||
std::ignore= invoker();
|
||||
breakpoint();
|
||||
return { TestResult::Failed, IOStreams::String() << "No exception was thrown, but " << Utility::fancyTypeName< T >() << " expected." };
|
||||
}
|
||||
catch( const T & )
|
||||
{
|
||||
return { TestResult::Passed, std::nullopt };
|
||||
}
|
||||
}
|
||||
catch( const T & )
|
||||
catch( const std::exception &ex )
|
||||
{
|
||||
return { TestResult::Passed, std::nullopt };
|
||||
return { TestResult::Failed, IOStreams::String() << "Incorrect exception type " << Utility::fancyTypeName( typeid( ex ) ) << " was thrown, but "
|
||||
<< Utility::fancyTypeName< T >() << " was expected." };
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
return { TestResult::Failed, IOStreams::String() << "Incorrect exception type (<Unknown>) was thrown, but "
|
||||
<< Utility::fancyTypeName< T >() << " was expected." };
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -183,9 +194,15 @@ namespace Alepha::Hydrogen::Testing ::detail:: TableTest_m
|
||||
std::ignore= invoker();
|
||||
return { TestResult::Passed, std::nullopt };
|
||||
}
|
||||
catch( const std::exception &ex )
|
||||
{
|
||||
return { TestResult::Failed, IOStreams::String() << "Exception type " << Utility::fancyTypeName( typeid( ex ) ) << " was thrown, but "
|
||||
"no exception was expected." };
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
return { TestResult::Failed, std::nullopt };
|
||||
return { TestResult::Failed, IOStreams::String() << "Exception type (<Unknown>) was thrown, but "
|
||||
"no exception was expected." };
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -198,21 +215,34 @@ namespace Alepha::Hydrogen::Testing ::detail:: TableTest_m
|
||||
{
|
||||
try
|
||||
{
|
||||
invoker();
|
||||
return { TestResult::Failed,
|
||||
IOStreams::String{} << "expected exception `" << typeid( T ).name() << "` wasn't thrown." };
|
||||
}
|
||||
catch( const T &ex )
|
||||
{
|
||||
const std::string witness= ex.what();
|
||||
const TestResult rv= witness == expected ? TestResult::Passed : TestResult::Failed;
|
||||
std::ostringstream oss;
|
||||
if( rv == TestResult::Failed )
|
||||
try
|
||||
{
|
||||
oss << "expected message did not match." << std::endl;
|
||||
streamDebugging< outputMode >( oss, witness, expected );
|
||||
invoker();
|
||||
return { TestResult::Failed,
|
||||
IOStreams::String{} << "expected exception `" << Utility::fancyTypeName< T >() << "` wasn't thrown." };
|
||||
}
|
||||
return { rv, oss.str().empty() ? std::optional< std::string >{} : std::move( oss ).str() };
|
||||
catch( const T &ex )
|
||||
{
|
||||
const std::string witness= ex.what();
|
||||
const TestResult rv= witness == expected ? TestResult::Passed : TestResult::Failed;
|
||||
std::ostringstream oss;
|
||||
if( rv == TestResult::Failed )
|
||||
{
|
||||
oss << "expected message did not match." << std::endl;
|
||||
streamDebugging< outputMode >( oss, witness, expected );
|
||||
}
|
||||
return { rv, oss.str().empty() ? std::optional< std::string >{} : std::move( oss ).str() };
|
||||
}
|
||||
}
|
||||
catch( const std::exception &ex )
|
||||
{
|
||||
return { TestResult::Failed, IOStreams::String() << "Incorrect exception type " << Utility::fancyTypeName( typeid( ex ) ) << " was thrown, but "
|
||||
<< Utility::fancyTypeName< T >() << " was expected." };
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
return { TestResult::Failed, IOStreams::String() << "Incorrect exception type (<Unknown>) was thrown, but "
|
||||
<< Utility::fancyTypeName< T >() << " was expected." };
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -303,7 +333,7 @@ namespace Alepha::Hydrogen::Testing ::detail:: TableTest_m
|
||||
{
|
||||
for( const auto [ comment, params, handler ]: initList )
|
||||
{
|
||||
if( C::debugCaseTypes ) std::cerr << boost::core::demangle( typeid( params ).name() ) << std::endl;
|
||||
if( C::debugCaseTypes ) std::cerr << Utility::fancyTypeName( typeid( params ) ) << std::endl;
|
||||
auto invoker= [=]
|
||||
{
|
||||
breakpoint();
|
||||
|
||||
Reference in New Issue
Block a user