2012-08-08 09:58:28 +02:00
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
*/
|
2012-10-16 09:27:21 +02:00
|
|
|
#ifndef TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_H_INCLUDED
|
|
|
|
#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_H_INCLUDED
|
2012-08-08 09:58:28 +02:00
|
|
|
|
|
|
|
#include "catch_tostring.hpp"
|
2012-10-16 09:31:05 +02:00
|
|
|
#include "catch_assertionresult.h"
|
2012-08-08 09:58:28 +02:00
|
|
|
#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;
|
|
|
|
|
2012-10-16 09:27:21 +02:00
|
|
|
class AssertionResultBuilder {
|
2012-08-08 09:58:28 +02:00
|
|
|
public:
|
|
|
|
|
2012-10-19 09:01:34 +02:00
|
|
|
AssertionResultBuilder( ResultWas::OfType resultType = ResultWas::Unknown );
|
2012-10-18 09:39:44 +02:00
|
|
|
AssertionResultBuilder( const AssertionResultBuilder& other );
|
|
|
|
AssertionResultBuilder& operator=(const AssertionResultBuilder& other );
|
2012-10-16 09:27:21 +02:00
|
|
|
|
|
|
|
AssertionResultBuilder& setResultType( ResultWas::OfType result );
|
2012-10-24 22:59:47 +02:00
|
|
|
AssertionResultBuilder& setResultType( bool result );
|
2012-10-16 09:27:21 +02:00
|
|
|
AssertionResultBuilder& setLhs( const std::string& lhs );
|
|
|
|
AssertionResultBuilder& setRhs( const std::string& rhs );
|
|
|
|
AssertionResultBuilder& setOp( const std::string& op );
|
2012-10-24 22:59:47 +02:00
|
|
|
|
|
|
|
AssertionResultBuilder& negate( bool shouldNegate );
|
2012-10-05 19:35:01 +02:00
|
|
|
|
2012-10-18 09:39:44 +02:00
|
|
|
template<typename T>
|
|
|
|
AssertionResultBuilder& operator << ( const T& value ) {
|
|
|
|
m_stream << value;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2012-10-24 22:59:47 +02:00
|
|
|
std::string reconstructExpression( const AssertionInfo& info ) const;
|
2012-10-05 19:35:01 +02:00
|
|
|
|
2012-10-24 22:59:47 +02:00
|
|
|
AssertionResultData build( const AssertionInfo& info ) const;
|
2012-10-05 19:35:01 +02:00
|
|
|
|
|
|
|
// Disable attempts to use || and && in expressions (without parantheses)
|
2012-08-08 09:58:28 +02:00
|
|
|
template<typename RhsT>
|
2012-10-03 19:12:57 +02:00
|
|
|
STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( const RhsT& );
|
2012-08-08 09:58:28 +02:00
|
|
|
template<typename RhsT>
|
2012-10-03 19:12:57 +02:00
|
|
|
STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( const RhsT& );
|
2012-10-04 09:09:09 +02:00
|
|
|
|
2012-10-05 19:35:01 +02:00
|
|
|
private:
|
2012-10-16 09:33:13 +02:00
|
|
|
AssertionResultData m_data;
|
2012-10-18 09:39:44 +02:00
|
|
|
struct ExprComponents {
|
2012-10-24 22:59:47 +02:00
|
|
|
ExprComponents() : shouldNegate( false ) {}
|
|
|
|
bool shouldNegate;
|
2012-10-18 09:39:44 +02:00
|
|
|
std::string lhs, rhs, op;
|
|
|
|
} m_exprComponents;
|
|
|
|
std::ostringstream m_stream;
|
2012-10-05 19:35:01 +02:00
|
|
|
};
|
2012-08-08 09:58:28 +02:00
|
|
|
|
|
|
|
} // end namespace Catch
|
|
|
|
|
2012-10-16 09:27:21 +02:00
|
|
|
#endif // TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_H_INCLUDED
|