Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include/internal/catch_assertionresult.cpp
diff options
context:
space:
mode:
authorPhil Nash2017-08-08 17:53:01 +0100
committerPhil Nash2017-08-08 17:53:01 +0100
commitf247ce5bff025281d4a7e9fa76aa78eb8479ddfe (patch)
tree45de7761cc0a728936161d96e785ae397106c72c /include/internal/catch_assertionresult.cpp
parentf8148ebae1e07c5609ed0af5993694e2972d0dfd (diff)
downloadcatch3-f247ce5bff025281d4a7e9fa76aa78eb8479ddfe.tar.gz
First cut of new AssertionHandler/ Decomposer
- integrated into INTERNAL_CATCH_TEST. Needs more work to fully replace existing stuff
Diffstat (limited to 'include/internal/catch_assertionresult.cpp')
-rw-r--r--include/internal/catch_assertionresult.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/include/internal/catch_assertionresult.cpp b/include/internal/catch_assertionresult.cpp
index 6819cd63..877f53bf 100644
--- a/include/internal/catch_assertionresult.cpp
+++ b/include/internal/catch_assertionresult.cpp
@@ -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 {