diff options
| author | Martin Hořeňovský | 2017-11-10 21:43:23 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2017-11-12 11:49:36 +0100 |
| commit | 8dbaac61ff39c7b99a31d5548df17cdc16bca322 (patch) | |
| tree | d80b30bc2ef674ec897c7c7989ba41024f2a94dc /include/internal | |
| parent | a0dbc62955a1b642d4ab2df9948bcbe4e7da4cc4 (diff) | |
| download | catch3-8dbaac61ff39c7b99a31d5548df17cdc16bca322.tar.gz | |
Final set of fixes for floating matchers approvals
Diffstat (limited to 'include/internal')
| -rw-r--r-- | include/internal/catch_matchers_floating.cpp | 7 | ||||
| -rw-r--r-- | include/internal/catch_tostring.cpp | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/include/internal/catch_matchers_floating.cpp b/include/internal/catch_matchers_floating.cpp index fb5f8d6a..3d2e342a 100644 --- a/include/internal/catch_matchers_floating.cpp +++ b/include/internal/catch_matchers_floating.cpp @@ -6,8 +6,9 @@ */ #include "catch_matchers_floating.h" +#include "catch_tostring.h" -#include <cmath> +#include <cstdlib> #include <cstdint> #include <cstring> #include <stdexcept> @@ -87,7 +88,7 @@ namespace Floating { } std::string WithinAbsMatcher::describe() const { - return "is within " + std::to_string(m_margin) + " of " + std::to_string(m_target); + return "is within " + ::Catch::Detail::stringify(m_margin) + " of " + ::Catch::Detail::stringify(m_target); } @@ -110,7 +111,7 @@ namespace Floating { } std::string WithinUlpsMatcher::describe() const { - return "is within " + std::to_string(m_ulps) + " ULPs of " + std::to_string(m_target) + ((m_type == FloatingPointKind::Float)? "f" : ""); + return "is within " + std::to_string(m_ulps) + " ULPs of " + ::Catch::Detail::stringify(m_target) + ((m_type == FloatingPointKind::Float)? "f" : ""); } }// namespace Floating diff --git a/include/internal/catch_tostring.cpp b/include/internal/catch_tostring.cpp index dc6f3af5..700315de 100644 --- a/include/internal/catch_tostring.cpp +++ b/include/internal/catch_tostring.cpp @@ -17,6 +17,7 @@ #include "catch_interfaces_config.h" #include "catch_context.h" +#include <cmath> #include <iomanip> namespace Catch { @@ -63,6 +64,10 @@ namespace Detail { template<typename T> std::string fpToString( T value, int precision ) { + if (std::isnan(value)) { + return "nan"; + } + ReusableStringStream rss; rss << std::setprecision( precision ) << std::fixed |