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

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorPhil Nash2012-08-08 08:50:38 +0100
committerPhil Nash2012-08-08 08:50:38 +0100
commitffe986d4ee94622cc41ad205adfb5b8e9ca65277 (patch)
tree5579e9d308ce86f927cae1fb7d13ab97b177adaf /include
parentfb386f458d7305dc8f88de0759caa19ea0eb0c50 (diff)
downloadcatch3-ffe986d4ee94622cc41ad205adfb5b8e9ca65277.tar.gz
Split result info from impl
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_expression_builder.hpp2
-rw-r--r--include/internal/catch_impl.hpp4
-rw-r--r--include/internal/catch_resultinfo.h55
-rw-r--r--include/internal/catch_resultinfo.hpp194
-rw-r--r--include/internal/catch_resultinfo_builder.hpp2
-rw-r--r--include/internal/catch_tostring.hpp3
6 files changed, 150 insertions, 110 deletions
diff --git a/include/internal/catch_expression_builder.hpp b/include/internal/catch_expression_builder.hpp
index 97f9c214..4296146d 100644
--- a/include/internal/catch_expression_builder.hpp
+++ b/include/internal/catch_expression_builder.hpp
@@ -11,7 +11,7 @@
#include "catch_expression.hpp"
#include "catch_resultinfo_builder.hpp"
#include "catch_tostring.hpp"
-#include "catch_resultinfo.hpp"
+#include "catch_resultinfo.h"
#include "catch_result_type.h"
#include "catch_context.h"
#include "catch_common.h"
diff --git a/include/internal/catch_impl.hpp b/include/internal/catch_impl.hpp
index 0157c72e..4cb99083 100644
--- a/include/internal/catch_impl.hpp
+++ b/include/internal/catch_impl.hpp
@@ -6,9 +6,11 @@
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
+// Collect all the implementation files together here
+// These are the equivalent of what would usually be cpp files
#include "catch_registry_hub.hpp"
#include "catch_notimplemented_exception.hpp"
#include "catch_context_impl.hpp"
#include "catch_console_colour_impl.hpp"
#include "catch_generators_impl.hpp"
-// !TBD... migrate all impl headers here
+#include "catch_resultinfo.hpp"
diff --git a/include/internal/catch_resultinfo.h b/include/internal/catch_resultinfo.h
new file mode 100644
index 00000000..3ca6276e
--- /dev/null
+++ b/include/internal/catch_resultinfo.h
@@ -0,0 +1,55 @@
+/*
+ * Created by Phil on 28/10/2010.
+ * Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
+ *
+ * Distributed under the Boost Software License, Version 1.0. (See accompanying
+ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+#ifndef TWOBLUECUBES_CATCH_RESULT_INFO_H_INCLUDED
+#define TWOBLUECUBES_CATCH_RESULT_INFO_H_INCLUDED
+
+#include <string>
+#include "catch_result_type.h"
+
+namespace Catch {
+
+ class ResultInfo {
+ public:
+ ResultInfo();
+ ResultInfo( const char* expr,
+ ResultWas::OfType result,
+ bool isNot,
+ const SourceLineInfo& lineInfo,
+ const char* macroName,
+ const char* message );
+ virtual ~ResultInfo();
+
+ bool ok() const;
+ ResultWas::OfType getResultType() const;
+ bool hasExpression() const;
+ bool hasMessage() const;
+ std::string getExpression() const;
+ bool hasExpandedExpression() const;
+ std::string getExpandedExpression() const;
+ std::string getMessage() const;
+ std::string getFilename() const;
+ std::size_t getLine() const;
+ std::string getTestMacroName() const;
+
+ protected:
+
+ std::string getExpandedExpressionInternal() const;
+ bool isNotExpression( const char* expr );
+
+ protected:
+ std::string m_macroName;
+ SourceLineInfo m_lineInfo;
+ std::string m_expr, m_lhs, m_rhs, m_op;
+ std::string m_message;
+ ResultWas::OfType m_result;
+ bool m_isNot;
+ };
+
+} // end namespace Catch
+
+#endif // TWOBLUECUBES_CATCH_RESULT_INFO_H_INCLUDED
diff --git a/include/internal/catch_resultinfo.hpp b/include/internal/catch_resultinfo.hpp
index da291414..8ad836d8 100644
--- a/include/internal/catch_resultinfo.hpp
+++ b/include/internal/catch_resultinfo.hpp
@@ -1,6 +1,6 @@
/*
- * Created by Phil on 28/10/2010.
- * Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
+ * Created by Phil on 8/8/12
+ * Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -8,123 +8,109 @@
#ifndef TWOBLUECUBES_CATCH_RESULT_INFO_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_RESULT_INFO_HPP_INCLUDED
-#include <string>
-#include "catch_result_type.h"
+#include "catch_resultinfo.h"
namespace Catch {
- class ResultInfo {
- public:
- ResultInfo()
- : m_macroName(),
- m_expr(),
- m_lhs(),
- m_rhs(),
- m_op(),
- m_message(),
- m_result( ResultWas::Unknown ),
- m_isNot( false )
+ ResultInfo::ResultInfo()
+ : m_macroName(),
+ m_expr(),
+ m_lhs(),
+ m_rhs(),
+ m_op(),
+ m_message(),
+ m_result( ResultWas::Unknown ),
+ m_isNot( false )
{}
-
- ResultInfo( const char* expr,
- ResultWas::OfType result,
- bool isNot,
- const SourceLineInfo& lineInfo,
- const char* macroName,
- const char* message )
- : m_macroName( macroName ),
- m_lineInfo( lineInfo ),
- m_expr( expr ),
- m_lhs(),
- m_rhs(),
- m_op( isNotExpression( expr ) ? "!" : "" ),
- m_message( message ),
- m_result( result ),
- m_isNot( isNot )
+
+ ResultInfo::ResultInfo(const char* expr,
+ ResultWas::OfType result,
+ bool isNot,
+ const SourceLineInfo& lineInfo,
+ const char* macroName,
+ const char* message )
+ : m_macroName( macroName ),
+ m_lineInfo( lineInfo ),
+ m_expr( expr ),
+ m_lhs(),
+ m_rhs(),
+ m_op( isNotExpression( expr ) ? "!" : "" ),
+ m_message( message ),
+ m_result( result ),
+ m_isNot( isNot )
{
if( isNot )
m_expr = "!" + m_expr;
}
-
- virtual ~ResultInfo() {}
-
- bool ok() const {
- return ( m_result & ResultWas::FailureBit ) != ResultWas::FailureBit;
- }
-
- ResultWas::OfType getResultType() const {
- return m_result;
- }
-
- bool hasExpression() const {
- return !m_expr.empty();
- }
- bool hasMessage() const {
- return !m_message.empty();
- }
+ ResultInfo::~ResultInfo() {}
- std::string getExpression() const {
- return m_expr;
- }
+ bool ResultInfo::ok() const {
+ return ( m_result & ResultWas::FailureBit ) != ResultWas::FailureBit;
+ }
- bool hasExpandedExpression() const {
- return hasExpression() && getExpandedExpressionInternal() != m_expr;
- }
-
- std::string getExpandedExpression() const {
- return hasExpression() ? getExpandedExpressionInternal() : "";
- }
-
- std::string getMessage() const {
- return m_message;
- }
-
- std::string getFilename() const {
- return m_lineInfo.file;
- }
-
- std::size_t getLine() const {
- return m_lineInfo.line;
- }
-
- std::string getTestMacroName() const {
- return m_macroName;
- }
+ ResultWas::OfType ResultInfo::getResultType() const {
+ return m_result;
+ }
- protected:
-
- std::string getExpandedExpressionInternal() const {
- if( m_op == "" || m_isNot )
- return m_lhs.empty() ? m_expr : m_op + m_lhs;
- else if( m_op == "matches" )
- return m_lhs + " " + m_rhs;
- else if( m_op != "!" )
- {
- if( m_lhs.size() + m_rhs.size() < 30 )
- return m_lhs + " " + m_op + " " + m_rhs;
- else if( m_lhs.size() < 70 && m_rhs.size() < 70 )
- return "\n\t" + m_lhs + "\n\t" + m_op + "\n\t" + m_rhs;
- else
- return "\n" + m_lhs + "\n" + m_op + "\n" + m_rhs + "\n\n";
- }
+ bool ResultInfo::hasExpression() const {
+ return !m_expr.empty();
+ }
+
+ bool ResultInfo::hasMessage() const {
+ return !m_message.empty();
+ }
+
+ std::string ResultInfo::getExpression() const {
+ return m_expr;
+ }
+
+ bool ResultInfo::hasExpandedExpression() const {
+ return hasExpression() && getExpandedExpressionInternal() != m_expr;
+ }
+
+ std::string ResultInfo::getExpandedExpression() const {
+ return hasExpression() ? getExpandedExpressionInternal() : "";
+ }
+
+ std::string ResultInfo::getMessage() const {
+ return m_message;
+ }
+
+ std::string ResultInfo::getFilename() const {
+ return m_lineInfo.file;
+ }
+
+ std::size_t ResultInfo::getLine() const {
+ return m_lineInfo.line;
+ }
+
+ std::string ResultInfo::getTestMacroName() const {
+ return m_macroName;
+ }
+
+ std::string ResultInfo::getExpandedExpressionInternal() const {
+ if( m_op == "" || m_isNot )
+ return m_lhs.empty() ? m_expr : m_op + m_lhs;
+ else if( m_op == "matches" )
+ return m_lhs + " " + m_rhs;
+ else if( m_op != "!" )
+ {
+ if( m_lhs.size() + m_rhs.size() < 30 )
+ return m_lhs + " " + m_op + " " + m_rhs;
+ else if( m_lhs.size() < 70 && m_rhs.size() < 70 )
+ return "\n\t" + m_lhs + "\n\t" + m_op + "\n\t" + m_rhs;
else
- return "{can't expand - use " + m_macroName + "_FALSE( " + m_expr.substr(1) + " ) instead of " + m_macroName + "( " + m_expr + " ) for better diagnostics}";
+ return "\n" + m_lhs + "\n" + m_op + "\n" + m_rhs + "\n\n";
}
+ else
+ return "{can't expand - use " + m_macroName + "_FALSE( " + m_expr.substr(1) + " ) instead of " + m_macroName + "( " + m_expr + " ) for better diagnostics}";
+ }
+
+ bool ResultInfo::isNotExpression( const char* expr ) {
+ return expr && expr[0] == '!';
+ }
- bool isNotExpression( const char* expr ) {
- return expr && expr[0] == '!';
- }
-
- protected:
- std::string m_macroName;
- SourceLineInfo m_lineInfo;
- std::string m_expr, m_lhs, m_rhs, m_op;
- std::string m_message;
- ResultWas::OfType m_result;
- bool m_isNot;
- };
-
} // end namespace Catch
#endif // TWOBLUECUBES_CATCH_RESULT_INFO_HPP_INCLUDED
diff --git a/include/internal/catch_resultinfo_builder.hpp b/include/internal/catch_resultinfo_builder.hpp
index 4712f48a..53445e92 100644
--- a/include/internal/catch_resultinfo_builder.hpp
+++ b/include/internal/catch_resultinfo_builder.hpp
@@ -9,7 +9,7 @@
#define TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_HPP_INCLUDED
#include "catch_tostring.hpp"
-#include "catch_resultinfo.hpp"
+#include "catch_resultinfo.h"
#include "catch_result_type.h"
#include "catch_evaluate.hpp"
#include "catch_common.h"
diff --git a/include/internal/catch_tostring.hpp b/include/internal/catch_tostring.hpp
index 455e186a..132d941a 100644
--- a/include/internal/catch_tostring.hpp
+++ b/include/internal/catch_tostring.hpp
@@ -136,9 +136,6 @@ inline std::string toString( std::nullptr_t ) {
#endif
#ifdef __OBJC__
- // inline std::string toString( NSString* const& nsstring ) {
- // return std::string( "@\"" ) + [nsstring UTF8String] + "\"";
- // }
inline std::string toString( NSString const * const& nsstring ) {
return std::string( "@\"" ) + [nsstring UTF8String] + "\"";
}