Sha256: 84375d89acdd35d9e2b627077ba4051c0beb85b080b165d1d439e4e515076246
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 KB
Contents
// Copyright Joakim Karlsson & Kim Gräsman 2010-2012. // 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 IGLOO_EQUALSWITHDELTACONSTRAINT_H #define IGLOO_EQUALSWITHDELTACONSTRAINT_H #include "./expressions/expression.h" namespace snowhouse { template< typename ExpectedType, typename DeltaType > struct EqualsWithDeltaConstraint : Expression< EqualsWithDeltaConstraint<ExpectedType, DeltaType> > { EqualsWithDeltaConstraint(const ExpectedType& expected, const DeltaType& delta) : m_expected(expected), m_delta(delta) { } template<typename ActualType> bool operator()(const ActualType& actual) const { return ((m_expected <= (actual + m_delta)) && (m_expected >= (actual - m_delta))); } ExpectedType m_expected; DeltaType m_delta; }; template< typename ExpectedType, typename DeltaType > inline EqualsWithDeltaConstraint<ExpectedType, DeltaType> EqualsWithDelta(const ExpectedType& expected, const DeltaType& delta) { return EqualsWithDeltaConstraint<ExpectedType, DeltaType>(expected, delta); } template< typename ExpectedType, typename DeltaType > struct Stringizer< EqualsWithDeltaConstraint< ExpectedType, DeltaType > > { static std::string ToString(const EqualsWithDeltaConstraint<ExpectedType, DeltaType>& constraint) { std::ostringstream builder; builder << "equal to " << snowhouse::Stringize(constraint.m_expected) << " (+/- " << snowhouse::Stringize(constraint.m_delta) << ")"; return builder.str(); } }; } #endif
Version data entries
2 entries across 2 versions & 1 rubygems