From 2adc3c0e230d55a1bd38f1811bf7a12800febd31 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Sun, 6 Mar 2022 12:43:48 -0700 Subject: [PATCH] Increase precision of `sf::Rect` operator<< This has been a recurring problem. I had to add similar code to the sf::Angle operator<< because I was getting tiny floating point differences that after rounding were imperceptable. --- test/TestUtilities/GraphicsUtil.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/TestUtilities/GraphicsUtil.hpp b/test/TestUtilities/GraphicsUtil.hpp index 44b3c3ba..5c355b70 100644 --- a/test/TestUtilities/GraphicsUtil.hpp +++ b/test/TestUtilities/GraphicsUtil.hpp @@ -9,6 +9,8 @@ #include "WindowUtil.hpp" #include +#include +#include namespace sf { @@ -23,7 +25,10 @@ namespace sf template std::ostream& operator <<(std::ostream& os, const sf::Rect& rect) { + const auto flags = os.flags(); + os << std::fixed << std::setprecision(std::numeric_limits::max_digits10); os << "(left=" << rect.left << ", top=" << rect.top << ", width=" << rect.width << ", height=" << rect.height << ")"; + os.flags(flags); return os; } }