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"
|
2012-10-16 03:31:05 -04:00
|
|
|
#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 {
|
2012-10-26 04:05:36 -04: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 03:45:23 -04:00
|
|
|
class ExpressionResultBuilder {
|
2012-08-08 03:58:28 -04:00
|
|
|
public:
|
|
|
|
|
2012-10-26 03:45:23 -04:00
|
|
|
ExpressionResultBuilder( ResultWas::OfType resultType = ResultWas::Unknown );
|
|
|
|
ExpressionResultBuilder( const ExpressionResultBuilder& other );
|
|
|
|
ExpressionResultBuilder& operator=(const ExpressionResultBuilder& other );
|
2012-10-16 03:27:21 -04:00
|
|
|
|
2012-10-26 03:45:23 -04: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 16:59:47 -04:00
|
|
|
|
2012-11-10 13:43:23 -05:00
|
|
|
ExpressionResultBuilder& endExpression( ResultDisposition::Flags resultDisposition );
|
2012-10-05 13:35:01 -04:00
|
|
|
|
2012-10-18 03:39:44 -04:00
|
|
|
template<typename T>
|
2012-10-26 03:45:23 -04:00
|
|
|
ExpressionResultBuilder& operator << ( const T& value ) {
|
2012-10-18 03:39:44 -04:00
|
|
|
m_stream << value;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2012-10-24 16:59:47 -04:00
|
|
|
std::string reconstructExpression( const AssertionInfo& info ) const;
|
2012-10-05 13:35:01 -04:00
|
|
|
|
2012-10-26 04:05:36 -04:00
|
|
|
AssertionResult buildResult( const AssertionInfo& info ) const;
|
2012-10-05 13:35:01 -04:00
|
|
|
|
|
|
|
private:
|
2012-10-16 03:33:13 -04:00
|
|
|
AssertionResultData m_data;
|
2012-10-18 03:39:44 -04:00
|
|
|
struct ExprComponents {
|
2012-10-24 16:59:47 -04:00
|
|
|
ExprComponents() : shouldNegate( false ) {}
|
|
|
|
bool shouldNegate;
|
2012-10-18 03:39:44 -04:00
|
|
|
std::string lhs, rhs, op;
|
|
|
|
} m_exprComponents;
|
|
|
|
std::ostringstream m_stream;
|
2012-10-05 13:35:01 -04:00
|
|
|
};
|
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
|