catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Small defensive tweak on checking expression
- Commit
01234172a9d9a4bf00b3f93535b16634fe7b282a- Author
- Phil Nash ·
- Parents
e401601ac128
Changes
internal/catch_resultinfo.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/catch_resultinfo.hpp b/internal/catch_resultinfo.hpp index f7e7f96b..9ddb2730 100644 --- a/internal/catch_resultinfo.hpp +++ b/internal/catch_resultinfo.hpp @@ -44,7 +44,7 @@ namespace Catch m_filename( filename ), m_line( line ), m_expr( expr ), - m_op( m_expr[0] == '!' ? "!" : "" ), + m_op( isNotExpression( expr ) ? "!" : "" ), m_result( result ), m_isNot( isNot ), m_expressionIncomplete( false ) @@ -152,6 +152,15 @@ namespace Catch else return "{can't expand - use " + m_macroName + "_NOT( " + m_expr.substr(1) + " ) instead of " + m_macroName + "( " + m_expr + " ) for better diagnostics}"; } + + /////////////////////////////////////////////////////////////////////////// + bool isNotExpression + ( + const char* expr + ) + { + return expr && expr[0] == '!'; + } protected: std::string m_macroName;