mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Final set of fixes for floating matchers approvals
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user