Catch/include/internal/catch_assertionresult_builder.h

65 lines
2.2 KiB
C
Raw Normal View History

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