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 {
|
2012-10-26 10:05:36 +02:00
|
|
|
|
|
|
|
// Wraps the (stringised versions of) the lhs, operator and rhs of an expression - as well as
|
|
|
|
// the result of evaluating it. This is used to build an AssertionResult object
|
2012-10-26 09:45:23 +02:00
|
|
|
class ExpressionResultBuilder {
|
2012-08-08 09:58:28 +02:00
|
|
|
public:
|
|
|
|
|
2012-10-26 09:45:23 +02:00
|
|
|
ExpressionResultBuilder( ResultWas::OfType resultType = ResultWas::Unknown );
|
|
|
|
ExpressionResultBuilder( const ExpressionResultBuilder& other );
|
|
|
|
ExpressionResultBuilder& operator=(const ExpressionResultBuilder& other );
|
2012-10-16 09:27:21 +02:00
|
|
|
|
2012-10-26 09:45:23 +02:00
|
|
|
ExpressionResultBuilder& setResultType( ResultWas::OfType result );
|
|
|
|
ExpressionResultBuilder& setResultType( bool result );
|
|
|
|
ExpressionResultBuilder& setLhs( const std::string& lhs );
|
|
|
|
ExpressionResultBuilder& setRhs( const std::string& rhs );
|
|
|
|
ExpressionResultBuilder& setOp( const std::string& op );
|
2012-10-24 22:59:47 +02:00
|
|
|
|
2012-11-10 19:43:23 +01:00
|
|
|
ExpressionResultBuilder& endExpression( ResultDisposition::Flags resultDisposition );
|
2012-10-05 19:35:01 +02:00
|
|
|
|
2012-10-18 09:39:44 +02:00
|
|
|
template<typename T>
|
2012-10-26 09:45:23 +02:00
|
|
|
ExpressionResultBuilder& operator << ( const T& value ) {
|
2012-10-18 09:39:44 +02:00
|
|
|
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-26 10:05:36 +02:00
|
|
|
AssertionResult buildResult( const AssertionInfo& info ) const;
|
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
|