mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Split out non-templated Approx methods into cpp file
This commit is contained in:
parent
0a614ee5ba
commit
edbe122761
@ -193,6 +193,7 @@ set(INTERNAL_HEADERS
|
|||||||
${HEADER_DIR}/internal/catch_xmlwriter.hpp
|
${HEADER_DIR}/internal/catch_xmlwriter.hpp
|
||||||
)
|
)
|
||||||
set(IMPL_SOURCES
|
set(IMPL_SOURCES
|
||||||
|
${HEADER_DIR}/internal/catch_approx.cpp
|
||||||
${HEADER_DIR}/internal/catch_assertionresult.cpp
|
${HEADER_DIR}/internal/catch_assertionresult.cpp
|
||||||
${HEADER_DIR}/internal/catch_commandline.cpp
|
${HEADER_DIR}/internal/catch_commandline.cpp
|
||||||
${HEADER_DIR}/internal/catch_common.cpp
|
${HEADER_DIR}/internal/catch_common.cpp
|
||||||
|
39
include/internal/catch_approx.cpp
Normal file
39
include/internal/catch_approx.cpp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* 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)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "catch_approx.hpp"
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
namespace Catch {
|
||||||
|
namespace Detail {
|
||||||
|
|
||||||
|
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
|
@ -20,18 +20,9 @@ namespace Detail {
|
|||||||
|
|
||||||
class Approx {
|
class Approx {
|
||||||
public:
|
public:
|
||||||
explicit Approx ( double value )
|
explicit Approx ( double value );
|
||||||
: m_epsilon( std::numeric_limits<float>::epsilon()*100 ),
|
|
||||||
m_margin( 0.0 ),
|
|
||||||
m_scale( 1.0 ),
|
|
||||||
m_value( value )
|
|
||||||
{}
|
|
||||||
|
|
||||||
Approx( Approx const& other ) = default;
|
static Approx custom();
|
||||||
|
|
||||||
static Approx custom() {
|
|
||||||
return Approx( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||||
Approx operator()( T value ) {
|
Approx operator()( T value ) {
|
||||||
@ -111,12 +102,7 @@ namespace Detail {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string toString() const;
|
||||||
std::string toString() const {
|
|
||||||
std::ostringstream oss;
|
|
||||||
oss << "Approx( " << ::Catch::Detail::stringify( m_value ) << " )";
|
|
||||||
return oss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_epsilon;
|
double m_epsilon;
|
||||||
@ -128,9 +114,7 @@ namespace Detail {
|
|||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct StringMaker<Catch::Detail::Approx> {
|
struct StringMaker<Catch::Detail::Approx> {
|
||||||
static std::string convert(Catch::Detail::Approx const& value) {
|
static std::string convert(Catch::Detail::Approx const& value);
|
||||||
return value.toString();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
Loading…
Reference in New Issue
Block a user