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

summaryrefslogtreecommitdiffhomepage
path: root/include/internal
diff options
context:
space:
mode:
authorPhil Nash2012-08-08 08:58:28 +0100
committerPhil Nash2012-08-08 08:58:28 +0100
commitc436a4dac153354dfdde0edfb5cab97e588ddca0 (patch)
tree16dba133fde85f82a814a9542e611b30aa3986ef /include/internal
parentffe986d4ee94622cc41ad205adfb5b8e9ca65277 (diff)
downloadcatch3-c436a4dac153354dfdde0edfb5cab97e588ddca0.tar.gz
Separated resultinfo_builder from impl
Diffstat (limited to 'include/internal')
-rw-r--r--include/internal/catch_expression.hpp2
-rw-r--r--include/internal/catch_expression_builder.hpp2
-rw-r--r--include/internal/catch_impl.hpp1
-rw-r--r--include/internal/catch_resultinfo_builder.h77
-rw-r--r--include/internal/catch_resultinfo_builder.hpp83
5 files changed, 100 insertions, 65 deletions
diff --git a/include/internal/catch_expression.hpp b/include/internal/catch_expression.hpp
index f7c570ea..ad78a909 100644
--- a/include/internal/catch_expression.hpp
+++ b/include/internal/catch_expression.hpp
@@ -8,7 +8,7 @@
#ifndef TWOBLUECUBES_CATCH_EXPRESSION_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_EXPRESSION_HPP_INCLUDED
-#include "catch_resultinfo_builder.hpp"
+#include "catch_resultinfo_builder.h"
#include "catch_evaluate.hpp"
namespace Catch {
diff --git a/include/internal/catch_expression_builder.hpp b/include/internal/catch_expression_builder.hpp
index 4296146d..1f8487f8 100644
--- a/include/internal/catch_expression_builder.hpp
+++ b/include/internal/catch_expression_builder.hpp
@@ -9,7 +9,7 @@
#define TWOBLUECUBES_CATCH_EXPRESSION_BUILDER_HPP_INCLUDED
#include "catch_expression.hpp"
-#include "catch_resultinfo_builder.hpp"
+#include "catch_resultinfo_builder.h"
#include "catch_tostring.hpp"
#include "catch_resultinfo.h"
#include "catch_result_type.h"
diff --git a/include/internal/catch_impl.hpp b/include/internal/catch_impl.hpp
index 4cb99083..5320d8d8 100644
--- a/include/internal/catch_impl.hpp
+++ b/include/internal/catch_impl.hpp
@@ -14,3 +14,4 @@
#include "catch_console_colour_impl.hpp"
#include "catch_generators_impl.hpp"
#include "catch_resultinfo.hpp"
+#include "catch_resultinfo_builder.hpp"
diff --git a/include/internal/catch_resultinfo_builder.h b/include/internal/catch_resultinfo_builder.h
new file mode 100644
index 00000000..d236a884
--- /dev/null
+++ b/include/internal/catch_resultinfo_builder.h
@@ -0,0 +1,77 @@
+/*
+ * Created by Phil on 8/5/2012.
+ * 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)
+ */
+#ifndef TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_H_INCLUDED
+#define TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_H_INCLUDED
+
+#include "catch_tostring.hpp"
+#include "catch_resultinfo.h"
+#include "catch_result_type.h"
+#include "catch_evaluate.hpp"
+#include "catch_common.h"
+
+namespace Catch {
+
+struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
+
+class ResultInfoBuilder : public ResultInfo {
+
+public:
+
+ ResultInfoBuilder();
+
+ ResultInfoBuilder( const char* expr,
+ bool isNot,
+ const SourceLineInfo& lineInfo,
+ const char* macroName,
+ const char* message = "" );
+
+ void setResultType( ResultWas::OfType result );
+ void setMessage( const std::string& message );
+ void setLineInfo( const SourceLineInfo& lineInfo );
+ void setLhs( const std::string& lhs );
+ void setRhs( const std::string& rhs );
+ void setOp( const std::string& op );
+
+ template<typename RhsT>
+ STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator ||
+ (
+ const RhsT&
+ );
+
+ template<typename RhsT>
+ STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator &&
+ (
+ const RhsT&
+ );
+
+private:
+ friend class ExpressionBuilder;
+ template<typename T> friend class Expression;
+
+ template<typename T> friend class PtrExpression;
+
+ ResultInfoBuilder& captureBoolExpression( bool result );
+
+ template<Internal::Operator Op, typename T1, typename T2>
+ ResultInfoBuilder& captureExpression( const T1& lhs, const T2& rhs ) {
+ setResultType( Internal::compare<Op>( lhs, rhs ) ? ResultWas::Ok : ResultWas::ExpressionFailed );
+ m_lhs = Catch::toString( lhs );
+ m_rhs = Catch::toString( rhs );
+ m_op = Internal::OperatorTraits<Op>::getName();
+ return *this;
+ }
+
+ template<Internal::Operator Op, typename T>
+ ResultInfoBuilder& captureExpression( const T* lhs, int rhs ) {
+ return captureExpression<Op>( lhs, reinterpret_cast<const T*>( rhs ) );
+ }
+};
+
+} // end namespace Catch
+
+#endif // TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_H_INCLUDED
diff --git a/include/internal/catch_resultinfo_builder.hpp b/include/internal/catch_resultinfo_builder.hpp
index 53445e92..0dd87308 100644
--- a/include/internal/catch_resultinfo_builder.hpp
+++ b/include/internal/catch_resultinfo_builder.hpp
@@ -1,5 +1,5 @@
/*
- * Created by Phil on 8/5/2012.
+ * Created by Phil on 8/8/2012.
* Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -8,100 +8,57 @@
#ifndef TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_HPP_INCLUDED
-#include "catch_tostring.hpp"
-#include "catch_resultinfo.h"
-#include "catch_result_type.h"
-#include "catch_evaluate.hpp"
-#include "catch_common.h"
+#include "catch_resultinfo_builder.h"
namespace Catch {
-struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
-
-class ResultInfoBuilder : public ResultInfo {
+ ResultInfoBuilder::ResultInfoBuilder() {}
-public:
-
- ResultInfoBuilder() {}
-
- ResultInfoBuilder( const char* expr,
- bool isNot,
- const SourceLineInfo& lineInfo,
- const char* macroName,
- const char* message = "" )
+ ResultInfoBuilder::ResultInfoBuilder( const char* expr,
+ bool isNot,
+ const SourceLineInfo& lineInfo,
+ const char* macroName,
+ const char* message )
: ResultInfo( expr, ResultWas::Unknown, isNot, lineInfo, macroName, message )
{}
- void setResultType( ResultWas::OfType result ) {
+ void ResultInfoBuilder::setResultType( ResultWas::OfType result ) {
// Flip bool results if isNot is set
if( m_isNot && result == ResultWas::Ok )
m_result = ResultWas::ExpressionFailed;
else if( m_isNot && result == ResultWas::ExpressionFailed )
m_result = ResultWas::Ok;
else
- m_result = result;
+ m_result = result;
}
- void setMessage( const std::string& message ) {
+ void ResultInfoBuilder::setMessage( const std::string& message ) {
m_message = message;
}
-
- void setLineInfo( const SourceLineInfo& lineInfo ) {
+
+ void ResultInfoBuilder::setLineInfo( const SourceLineInfo& lineInfo ) {
m_lineInfo = lineInfo;
}
-
- void setLhs( const std::string& lhs ) {
+
+ void ResultInfoBuilder::setLhs( const std::string& lhs ) {
m_lhs = lhs;
}
-
- void setRhs( const std::string& rhs ) {
+
+ void ResultInfoBuilder::setRhs( const std::string& rhs ) {
m_rhs = rhs;
}
- void setOp( const std::string& op ) {
+ void ResultInfoBuilder::setOp( const std::string& op ) {
m_op = op;
}
-
- template<typename RhsT>
- STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator ||
- (
- const RhsT&
- );
-
- template<typename RhsT>
- STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator &&
- (
- const RhsT&
- );
-
-private:
- friend class ExpressionBuilder;
- template<typename T> friend class Expression;
- template<typename T> friend class PtrExpression;
-
- ResultInfoBuilder& captureBoolExpression( bool result ) {
+ ResultInfoBuilder& ResultInfoBuilder::captureBoolExpression( bool result ) {
m_lhs = Catch::toString( result );
m_op = m_isNot ? "!" : "";
setResultType( result ? ResultWas::Ok : ResultWas::ExpressionFailed );
return *this;
- }
-
- template<Internal::Operator Op, typename T1, typename T2>
- ResultInfoBuilder& captureExpression( const T1& lhs, const T2& rhs ) {
- setResultType( Internal::compare<Op>( lhs, rhs ) ? ResultWas::Ok : ResultWas::ExpressionFailed );
- m_lhs = Catch::toString( lhs );
- m_rhs = Catch::toString( rhs );
- m_op = Internal::OperatorTraits<Op>::getName();
- return *this;
}
-
- template<Internal::Operator Op, typename T>
- ResultInfoBuilder& captureExpression( const T* lhs, int rhs ) {
- return captureExpression<Op>( lhs, reinterpret_cast<const T*>( rhs ) );
- }
-};
-
+
} // end namespace Catch
#endif // TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_HPP_INCLUDED