From edbe12276143fb27a7f98c1af0e6f25c8787aae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Wed, 19 Jul 2017 10:01:06 +0200 Subject: [PATCH] Split out non-templated Approx methods into cpp file --- CMakeLists.txt | 1 + include/internal/catch_approx.cpp | 39 +++++++++++++++++++++++++++++++ include/internal/catch_approx.hpp | 24 ++++--------------- 3 files changed, 44 insertions(+), 20 deletions(-) create mode 100644 include/internal/catch_approx.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 2936a114..ff300ca7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -193,6 +193,7 @@ set(INTERNAL_HEADERS ${HEADER_DIR}/internal/catch_xmlwriter.hpp ) set(IMPL_SOURCES + ${HEADER_DIR}/internal/catch_approx.cpp ${HEADER_DIR}/internal/catch_assertionresult.cpp ${HEADER_DIR}/internal/catch_commandline.cpp ${HEADER_DIR}/internal/catch_common.cpp diff --git a/include/internal/catch_approx.cpp b/include/internal/catch_approx.cpp new file mode 100644 index 00000000..98fc7bce --- /dev/null +++ b/include/internal/catch_approx.cpp @@ -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 + +namespace Catch { +namespace Detail { + + Approx::Approx ( double value ) + : m_epsilon( std::numeric_limits::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::convert(Catch::Detail::Approx const& value) { + return value.toString(); +} + +} // end namespace Catch diff --git a/include/internal/catch_approx.hpp b/include/internal/catch_approx.hpp index 4235d0bc..bb930a4b 100644 --- a/include/internal/catch_approx.hpp +++ b/include/internal/catch_approx.hpp @@ -20,18 +20,9 @@ namespace Detail { class Approx { public: - explicit Approx ( double value ) - : m_epsilon( std::numeric_limits::epsilon()*100 ), - m_margin( 0.0 ), - m_scale( 1.0 ), - m_value( value ) - {} + explicit Approx ( double value ); - Approx( Approx const& other ) = default; - - static Approx custom() { - return Approx( 0 ); - } + static Approx custom(); template ::value>::type> Approx operator()( T value ) { @@ -111,12 +102,7 @@ namespace Detail { return *this; } - - std::string toString() const { - std::ostringstream oss; - oss << "Approx( " << ::Catch::Detail::stringify( m_value ) << " )"; - return oss.str(); - } + std::string toString() const; private: double m_epsilon; @@ -128,9 +114,7 @@ namespace Detail { template<> struct StringMaker { - static std::string convert(Catch::Detail::Approx const& value) { - return value.toString(); - } + static std::string convert(Catch::Detail::Approx const& value); }; } // end namespace Catch