/* * 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& setResultType( ResultWas::OfType result ); ResultInfoBuilder& setMessage( const std::string& message ); ResultInfoBuilder& setLineInfo( const SourceLineInfo& lineInfo ); ResultInfoBuilder& setLhs( const std::string& lhs ); ResultInfoBuilder& setRhs( const std::string& rhs ); ResultInfoBuilder& setOp( const std::string& op ); ResultInfoBuilder& setMacroName( const std::string& macroName ); template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( const RhsT& ); template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( const RhsT& ); private: ResultInfoBuilder( const char* expr, bool isNot, const SourceLineInfo& lineInfo, const char* macroName ); friend class ExpressionBuilder; template friend class Expression; template friend class PtrExpression; ResultInfoBuilder& captureBoolExpression( bool result ); template ResultInfoBuilder& captureExpression( const T1& lhs, const T2& rhs ) { setResultType( Internal::compare( lhs, rhs ) ? ResultWas::Ok : ResultWas::ExpressionFailed ); m_lhs = Catch::toString( lhs ); m_rhs = Catch::toString( rhs ); m_op = Internal::OperatorTraits::getName(); return *this; } template ResultInfoBuilder& captureExpression( const T* lhs, int rhs ) { return captureExpression( lhs, reinterpret_cast( rhs ) ); } }; } // end namespace Catch #endif // TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_H_INCLUDED