First cut of new AssertionHandler/ Decomposer

- integrated into INTERNAL_CATCH_TEST. Needs more work to fully replace existing stuff
This commit is contained in:
Phil Nash
2017-08-08 17:53:01 +01:00
parent f8148ebae1
commit f247ce5bff
14 changed files with 469 additions and 39 deletions

View File

@@ -24,17 +24,30 @@ namespace Catch {
resultType = ResultWas::Ok;
}
std::string const& AssertionResultData::reconstructExpression() const {
if( decomposedExpression != nullptr ) {
decomposedExpression->reconstructExpression( reconstructedExpression );
if( parenthesized ) {
reconstructedExpression.insert( 0, 1, '(' );
reconstructedExpression.append( 1, ')' );
std::string AssertionResultData::reconstructExpression() const {
if( reconstructedExpression.empty() ) {
// Try new LazyExpression first...
if( lazyExpression ) {
// !TBD Use stringstream for now, but rework above to pass stream in
std::ostringstream oss;
oss << lazyExpression;
reconstructedExpression = oss.str();
}
if( negated ) {
reconstructedExpression.insert( 0, 1, '!' );
// ... if not, fall back to decomposedExpression
else if( decomposedExpression != nullptr ) {
decomposedExpression->reconstructExpression( reconstructedExpression );
if( parenthesized ) {
reconstructedExpression.insert( 0, 1, '(' );
reconstructedExpression.append( 1, ')' );
}
if( negated ) {
reconstructedExpression.insert( 0, 1, '!' );
}
decomposedExpression = nullptr;
}
decomposedExpression = nullptr;
}
return reconstructedExpression;
}
@@ -85,7 +98,10 @@ namespace Catch {
}
std::string AssertionResult::getExpandedExpression() const {
return m_resultData.reconstructExpression();
std::string expr = m_resultData.reconstructExpression();
return expr.empty()
? getExpression()
: expr;
}
std::string AssertionResult::getMessage() const {