tinyformat icon indicating copy to clipboard operation
tinyformat copied to clipboard

Passing -INF through %.16d still puts the minus sign at far-left

Open duffy-ocraven opened this issue 4 years ago • 1 comments

Before #77 change gets widely circulated, check whether passing the negative -INF through %.16d still puts the minus sign at far-left

duffy-ocraven avatar Nov 16 '20 19:11 duffy-ocraven

A reproducer is

diff --git a/tinyformat_test.cpp b/tinyformat_test.cpp
index 4bb1d60..3e85007 100644
--- a/tinyformat_test.cpp
+++ b/tinyformat_test.cpp
@@ -222,6 +222,7 @@ int unitTests()
     CHECK_EQUAL(tfm::format("%.3d",   std::numeric_limits<double>::quiet_NaN()), "nan");
     CHECK_EQUAL(tfm::format("%.4d",   std::numeric_limits<double>::quiet_NaN()), " nan");
     CHECK_EQUAL(tfm::format("%04.0f", std::numeric_limits<double>::quiet_NaN()), " nan");
+    CHECK_EQUAL(tfm::format("%.5d", -std::numeric_limits<double>::infinity()), " -inf");
 #   endif

     //------------------------------------------------------------

which fails with

test failed, line 225
- inf !=  -inf
[tfm::format("%.5d", -std::numeric_limits<double>::infinity()), " -inf"]

bbannier avatar Feb 16 '21 10:02 bbannier