[PATCH] D146818: [support] Attempt to fix PrintNumber test for Solaris

Paul Kirth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 24 09:48:35 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6d5845c5c335: [support] Attempt to fix PrintNumber test for Solaris (authored by paulkirth).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146818/new/

https://reviews.llvm.org/D146818

Files:
  llvm/unittests/Support/ScopedPrinterTest.cpp


Index: llvm/unittests/Support/ScopedPrinterTest.cpp
===================================================================
--- llvm/unittests/Support/ScopedPrinterTest.cpp
+++ llvm/unittests/Support/ScopedPrinterTest.cpp
@@ -572,7 +572,7 @@
     W.printNumber("float-42.0", 42.0f);
     W.printNumber("float-42.5625", 42.5625f);
 
-        W.printNumber("double-max", MaxDouble);
+    W.printNumber("double-max", MaxDouble);
     W.printNumber("double-min", MinDouble);
     W.printNumber("double-inf", InfDouble);
     W.printNumber("double-nan", NaNDouble);
@@ -610,6 +610,19 @@
   format("%5.1f", NaNDouble).snprint(Buf, sizeof(Buf));
   std::string NaNDoubleStr(Buf);
 
+  format("%.*g", InfFloat).snprint(Buf, sizeof(Buf));
+  std::string JsonInfFloatStr(Buf);
+
+  format("%.*g", InfDouble).snprint(Buf, sizeof(Buf));
+  std::string JsonInfDoubleStr(Buf);
+
+  format("%.*g", NaNFloat).snprint(Buf, sizeof(Buf));
+  std::string JsonNaNFloatStr(Buf);
+
+  format("%.*g", NaNDouble).snprint(Buf, sizeof(Buf));
+  std::string JsonNaNDoubleStr(Buf);
+
+
   std::string ExpectedOut = Twine(
                                 R"(uint64_t-max: 18446744073709551615
 uint64_t-min: 0
@@ -669,14 +682,14 @@
   },
   "float-max": 3.4028234663852886e+38,
   "float-min": 1.1754943508222875e-38,
-  "float-inf": )" + std::to_string(InfFloat) + R"(,
-  "float-nan": )" + std::to_string(NaNFloat) + R"(,
+  "float-inf": )" + JsonInfFloatStr + R"(,
+  "float-nan": )" + JsonNaNFloatStr + R"(,
   "float-42.0": 42,
   "float-42.5625": 42.5625,
   "double-max": 1.7976931348623157e+308,
   "double-min": 2.2250738585072014e-308,
-  "double-inf": )" + std::to_string(InfDouble) + R"(,
-  "double-nan": )" + std::to_string(NaNDouble) + R"(,
+  "double-inf": )" + JsonInfDoubleStr + R"(,
+  "double-nan": )" + JsonNaNDoubleStr + R"(,
   "double-42.0": 42,
   "double-42.5625": 42.5625
 })").str();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146818.508139.patch
Type: text/x-patch
Size: 1879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230324/f2a4d1b3/attachment.bin>


More information about the llvm-commits mailing list