Skip to content

Commit c819257

Browse files
committed
[llvm][support] Fix ScopedPrinterTest on AIX
The test strings we used for infinity and NAN were not correct on AIX. This patch creates those dynamically instead of hard-coded. Reviewed By: abhina.sreeskantharajan Differential Revision: https://reviews.llvm.org/D146542
1 parent 651b405 commit c819257

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

llvm/unittests/Support/ScopedPrinterTest.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "llvm/Support/ScopedPrinter.h"
1010
#include "llvm/ADT/APSInt.h"
11+
#include "llvm/Support/Format.h"
1112
#include "gtest/gtest.h"
1213
#include <cmath>
1314
#include <vector>
@@ -594,6 +595,19 @@ TEST_F(ScopedPrinterTest, PrintNumber) {
594595
format("%5.1f", std::numeric_limits<double>::max()).snprint(Buf, sizeof(Buf));
595596
std::string MaxDoubleStr(Buf);
596597

598+
format("%5.1f", std::numeric_limits<double>::infinity())
599+
.snprint(Buf, sizeof(Buf));
600+
std::string InfFloatStr(Buf);
601+
602+
std::to_string(std::numeric_limits<float>::infinity());
603+
std::string InfDoubleStr(Buf);
604+
605+
format("%5.1f", std::nanf("1")).snprint(Buf, sizeof(Buf));
606+
std::string NaNFloatStr(Buf);
607+
608+
format("%5.1f", std::nan("1")).snprint(Buf, sizeof(Buf));
609+
std::string NaNDoubleStr(Buf);
610+
597611
std::string ExpectedOut = Twine(
598612
R"(uint64_t-max: 18446744073709551615
599613
uint64_t-min: 0
@@ -615,15 +629,15 @@ apsint: 9999999999999999999999
615629
label: value (0)
616630
float-max: )" + MaxFloatStr + R"(
617631
float-min: 0.0
618-
float-inf: inf
619-
float-nan: nan
632+
float-inf: )" + InfFloatStr + R"(
633+
float-nan: )" + NaNFloatStr + R"(
620634
float-42.0: 42.0
621635
float-42.5625: 42.6
622636
double-max: )" + MaxDoubleStr +
623637
R"(
624638
double-min: 0.0
625-
double-inf: inf
626-
double-nan: nan
639+
double-inf: )" + InfDoubleStr + R"(
640+
double-nan: )" + NaNDoubleStr + R"(
627641
double-42.0: 42.0
628642
double-42.5625: 42.6
629643
)")

0 commit comments

Comments
 (0)