aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-01-25 17:01:00 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-01-25 17:01:00 +0000
commitbd7561ea29649625775ef814dded2856d91c4dcf (patch)
tree0ab4354fbba1ae8def6c55bfed13d12911e6ac13 /unittests
parent5b7c05716791adba09bb342f10c5af2c702c675d (diff)
APFloat: Make sure that we get a well-formed x87 NaN when converting from a smaller type.
Fixes PR15054. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173459 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ADT/APFloatTest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/unittests/ADT/APFloatTest.cpp b/unittests/ADT/APFloatTest.cpp
index 7345e124cd..278983565c 100644
--- a/unittests/ADT/APFloatTest.cpp
+++ b/unittests/ADT/APFloatTest.cpp
@@ -794,6 +794,32 @@ TEST(APFloatTest, convert) {
test.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &losesInfo);
EXPECT_EQ(4294967295.0, test.convertToDouble());
EXPECT_FALSE(losesInfo);
+
+ test = APFloat::getSNaN(APFloat::IEEEsingle);
+ APFloat X87SNaN = APFloat::getSNaN(APFloat::x87DoubleExtended);
+ test.convert(APFloat::x87DoubleExtended, APFloat::rmNearestTiesToEven,
+ &losesInfo);
+ EXPECT_TRUE(test.bitwiseIsEqual(X87SNaN));
+ EXPECT_FALSE(losesInfo);
+
+ test = APFloat::getQNaN(APFloat::IEEEsingle);
+ APFloat X87QNaN = APFloat::getQNaN(APFloat::x87DoubleExtended);
+ test.convert(APFloat::x87DoubleExtended, APFloat::rmNearestTiesToEven,
+ &losesInfo);
+ EXPECT_TRUE(test.bitwiseIsEqual(X87QNaN));
+ EXPECT_FALSE(losesInfo);
+
+ test = APFloat::getSNaN(APFloat::x87DoubleExtended);
+ test.convert(APFloat::x87DoubleExtended, APFloat::rmNearestTiesToEven,
+ &losesInfo);
+ EXPECT_TRUE(test.bitwiseIsEqual(X87SNaN));
+ EXPECT_FALSE(losesInfo);
+
+ test = APFloat::getQNaN(APFloat::x87DoubleExtended);
+ test.convert(APFloat::x87DoubleExtended, APFloat::rmNearestTiesToEven,
+ &losesInfo);
+ EXPECT_TRUE(test.bitwiseIsEqual(X87QNaN));
+ EXPECT_FALSE(losesInfo);
}
TEST(APFloatTest, PPCDoubleDouble) {