From baf3d2f360c94ad5ef8c42387ded629a1d782ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sun, 19 Nov 2017 14:54:52 +0100 Subject: [PATCH] Split out ratio_string::symbol bodies --- include/catch.hpp | 1 + include/internal/catch_tostring.cpp | 11 +++++++++++ include/internal/catch_tostring.h | 16 +++++++++------- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/include/catch.hpp b/include/catch.hpp index ef141d8f..8294f404 100644 --- a/include/catch.hpp +++ b/include/catch.hpp @@ -30,6 +30,7 @@ # if defined(CATCH_CONFIG_DISABLE_MATCHERS) # undef CATCH_CONFIG_DISABLE_MATCHERS # endif +# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER #endif #if !defined(CATCH_CONFIG_IMPL_ONLY) diff --git a/include/internal/catch_tostring.cpp b/include/internal/catch_tostring.cpp index 700315de..a9f7735e 100644 --- a/include/internal/catch_tostring.cpp +++ b/include/internal/catch_tostring.cpp @@ -12,6 +12,10 @@ # pragma clang diagnostic ignored "-Wglobal-constructors" #endif +// Enable specific decls locally +#if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) +#define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER +#endif #include "catch_tostring.h" #include "catch_interfaces_config.h" @@ -221,6 +225,13 @@ std::string StringMaker::convert(double value) { return fpToString(value, 10); } +std::string ratio_string::symbol() { return "a"; } +std::string ratio_string::symbol() { return "f"; } +std::string ratio_string::symbol() { return "p"; } +std::string ratio_string::symbol() { return "n"; } +std::string ratio_string::symbol() { return "u"; } +std::string ratio_string::symbol() { return "m"; } + } // end namespace Catch diff --git a/include/internal/catch_tostring.h b/include/internal/catch_tostring.h index 374b5e9b..79e02448 100644 --- a/include/internal/catch_tostring.h +++ b/include/internal/catch_tostring.h @@ -351,6 +351,9 @@ namespace Catch { #include #include + +namespace Catch { + template struct ratio_string { static std::string symbol(); @@ -365,30 +368,29 @@ std::string ratio_string::symbol() { } template <> struct ratio_string { - static std::string symbol() { return "a"; } + static std::string symbol(); }; template <> struct ratio_string { - static std::string symbol() { return "f"; } + static std::string symbol(); }; template <> struct ratio_string { - static std::string symbol() { return "p"; } + static std::string symbol(); }; template <> struct ratio_string { - static std::string symbol() { return "n"; } + static std::string symbol(); }; template <> struct ratio_string { - static std::string symbol() { return "u"; } + static std::string symbol(); }; template <> struct ratio_string { - static std::string symbol() { return "m"; } + static std::string symbol(); }; -namespace Catch { //////////// // std::chrono::duration specializations template