[PATCH] D146542: [llvm][support] Fix ScopedPrinterTest on AIX

Paul Kirth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 21 09:44:29 PDT 2023


paulkirth created this revision.
paulkirth added reviewers: jhenderson, abhina.sreeskantharajan.
Herald added a project: All.
paulkirth requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The test strings we used for infinity and NAN were not correct on AIX.
This patch creates those dynamically instead of hard-coded.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146542

Files:
  llvm/unittests/Support/ScopedPrinterTest.cpp


Index: llvm/unittests/Support/ScopedPrinterTest.cpp
===================================================================
--- llvm/unittests/Support/ScopedPrinterTest.cpp
+++ llvm/unittests/Support/ScopedPrinterTest.cpp
@@ -8,6 +8,7 @@
 
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/ADT/APSInt.h"
+#include "llvm/Support/Format.h"
 #include "gtest/gtest.h"
 #include <cmath>
 #include <vector>
@@ -594,6 +595,18 @@
   format("%5.1f", std::numeric_limits<double>::max()).snprint(Buf, sizeof(Buf));
   std::string MaxDoubleStr(Buf);
 
+  format("%5.1f", std::numeric_limits<double>::infinity()).snprint(Buf, sizeof(Buf));
+  std::string InfFloatStr(Buf);
+
+  std::to_string(std::numeric_limits<float>::infinity());
+  std::string InfDoubleStr(Buf);
+
+  format("%5.1f", std::nanf("1")).snprint(Buf, sizeof(Buf));
+  std::string NaNFloatStr(Buf);
+
+  format("%5.1f", std::nan("1")).snprint(Buf, sizeof(Buf));
+  std::string NaNDoubleStr(Buf);
+
   std::string ExpectedOut = Twine(
                                 R"(uint64_t-max: 18446744073709551615
 uint64_t-min: 0
@@ -615,15 +628,15 @@
 label: value (0)
 float-max: )" + MaxFloatStr + R"(
 float-min:   0.0
-float-inf:   inf
-float-nan:   nan
+float-inf: )" + InfFloatStr + R"(
+float-nan: )" + NaNFloatStr + R"(
 float-42.0:  42.0
 float-42.5625:  42.6
 double-max: )" + MaxDoubleStr +
                                 R"(
 double-min:   0.0
-double-inf:   inf
-double-nan:   nan
+double-inf: )" + InfDoubleStr + R"(
+double-nan: )" + NaNDoubleStr + R"(
 double-42.0:  42.0
 double-42.5625:  42.6
 )")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146542.507022.patch
Type: text/x-patch
Size: 1567 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230321/8632de90/attachment.bin>


More information about the llvm-commits mailing list