2017-07-19 10:01:06 +02:00
|
|
|
/*
|
|
|
|
* Created by Martin on 19/07/2017.
|
|
|
|
* Copyright 2017 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)
|
|
|
|
*/
|
|
|
|
|
2017-09-07 12:24:33 +02:00
|
|
|
#include "catch_approx.h"
|
2017-07-19 10:01:06 +02:00
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
|
|
|
|
namespace Catch {
|
|
|
|
namespace Detail {
|
|
|
|
|
2017-08-17 15:34:00 +02:00
|
|
|
double max(double lhs, double rhs) {
|
|
|
|
if (lhs < rhs) {
|
|
|
|
return rhs;
|
|
|
|
}
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
|
2017-07-19 10:01:06 +02:00
|
|
|
Approx::Approx ( double value )
|
|
|
|
: m_epsilon( std::numeric_limits<float>::epsilon()*100 ),
|
|
|
|
m_margin( 0.0 ),
|
|
|
|
m_scale( 1.0 ),
|
|
|
|
m_value( value )
|
|
|
|
{}
|
|
|
|
|
|
|
|
Approx Approx::custom() {
|
|
|
|
return Approx( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Approx::toString() const {
|
|
|
|
std::ostringstream oss;
|
|
|
|
oss << "Approx( " << ::Catch::Detail::stringify( m_value ) << " )";
|
|
|
|
return oss.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace Detail
|
|
|
|
|
|
|
|
std::string StringMaker<Catch::Detail::Approx>::convert(Catch::Detail::Approx const& value) {
|
|
|
|
return value.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace Catch
|