summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/ADT')
-rw-r--r--llvm/unittests/ADT/APFloatTest.cpp17
-rw-r--r--llvm/unittests/ADT/StringRefTest.cpp7
2 files changed, 23 insertions, 1 deletions
diff --git a/llvm/unittests/ADT/APFloatTest.cpp b/llvm/unittests/ADT/APFloatTest.cpp
index 84fb6fad156..8b88c123b19 100644
--- a/llvm/unittests/ADT/APFloatTest.cpp
+++ b/llvm/unittests/ADT/APFloatTest.cpp
@@ -849,6 +849,23 @@ TEST(APFloatTest, fromDecimalString) {
EXPECT_EQ(2.71828, convertToDoubleFromString("2.71828"));
}
+TEST(APFloatTest, fromToStringSpecials) {
+ auto expects = [] (const char *first, const char *second) {
+ std::string roundtrip = convertToString(convertToDoubleFromString(second), 0, 3);
+ EXPECT_STREQ(first, roundtrip.c_str());
+ };
+ expects("+Inf", "+Inf");
+ expects("+Inf", "INFINITY");
+ expects("+Inf", "inf");
+ expects("-Inf", "-Inf");
+ expects("-Inf", "-INFINITY");
+ expects("-Inf", "-inf");
+ expects("NaN", "NaN");
+ expects("NaN", "nan");
+ expects("NaN", "-NaN");
+ expects("NaN", "-nan");
+}
+
TEST(APFloatTest, fromHexadecimalString) {
EXPECT_EQ( 1.0, APFloat(APFloat::IEEEdouble(), "0x1p0").convertToDouble());
EXPECT_EQ(+1.0, APFloat(APFloat::IEEEdouble(), "+0x1p0").convertToDouble());
diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp
index 0684afe678f..0e0b5957f02 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -875,7 +875,12 @@ struct GetDoubleStrings {
{"0.0", false, false, 0.0},
{"-0.0", false, false, -0.0},
{"123.45", false, true, 123.45},
- {"123.45", true, false, 123.45}};
+ {"123.45", true, false, 123.45},
+ {"1.8e308", true, false, std::numeric_limits<double>::infinity()},
+ {"1.8e308", false, true, std::numeric_limits<double>::infinity()},
+ {"0x0.0000000000001P-1023", false, true, 0.0},
+ {"0x0.0000000000001P-1023", true, false, 0.0},
+ };
TEST(StringRefTest, getAsDouble) {
for (const auto &Entry : DoubleStrings) {
OpenPOWER on IntegriCloud