summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/APFloatTest.cpp
diff options
context:
space:
mode:
authorMichael Gottesman <mgottesman@apple.com>2013-06-19 21:00:17 +0000
committerMichael Gottesman <mgottesman@apple.com>2013-06-19 21:00:17 +0000
commitd95d4478852c415460292ce45831028a9aa2e817 (patch)
treee4e61f3ab383d2310d04a9a5108817a5626266bc /llvm/unittests/ADT/APFloatTest.cpp
parentafc1036f3e4c66261800f4ea896cd393a079a1a3 (diff)
downloadbcm5719-llvm-d95d4478852c415460292ce45831028a9aa2e817.tar.gz
bcm5719-llvm-d95d4478852c415460292ce45831028a9aa2e817.zip
[APFloat] Added isFiniteNonZero predicate.
This is the first patch in a series of patches to rename isNormal => isFiniteNonZero and isIEEENormal => isNormal. In order to prevent careless errors on my part the overall plan is: 1. Add the isFiniteNonZero predicate with tests. I can do this in a method independent of isNormal. (This step is this patch). 2. Convert all references to isNormal with isFiniteNonZero. My plan is to comment out isNormal locally and continually convert isNormal references => isFiniteNonZero until llvm/clang compiles. 3. Remove old isNormal and rename isIEEENormal to isNormal. 4. Look through all of said references from patch 2 and see if we can simplify them by using the new isNormal. llvm-svn: 184350
Diffstat (limited to 'llvm/unittests/ADT/APFloatTest.cpp')
-rw-r--r--llvm/unittests/ADT/APFloatTest.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/APFloatTest.cpp b/llvm/unittests/ADT/APFloatTest.cpp
index e1b9158d555..186b15ac3b2 100644
--- a/llvm/unittests/ADT/APFloatTest.cpp
+++ b/llvm/unittests/ADT/APFloatTest.cpp
@@ -1458,4 +1458,32 @@ TEST(APFloatTest, isNaN) {
EXPECT_FALSE(APFloat(APFloat::IEEEsingle, "0x1p-159").isNaN());
}
+TEST(APFloatTest, isFiniteNonZero) {
+ // Test positive/negative normal value.
+ EXPECT_TRUE(APFloat(APFloat::IEEEsingle, "0x1p+0").isFiniteNonZero());
+ EXPECT_TRUE(APFloat(APFloat::IEEEsingle, "-0x1p+0").isFiniteNonZero());
+
+ // Test positive/negative denormal value.
+ EXPECT_TRUE(APFloat(APFloat::IEEEsingle, "0x1p-149").isFiniteNonZero());
+ EXPECT_TRUE(APFloat(APFloat::IEEEsingle, "-0x1p-149").isFiniteNonZero());
+
+ // Test +/- Infinity.
+ EXPECT_FALSE(APFloat::getInf(APFloat::IEEEsingle, false).isFiniteNonZero());
+ EXPECT_FALSE(APFloat::getInf(APFloat::IEEEsingle, true).isFiniteNonZero());
+
+ // Test +/- Zero.
+ EXPECT_FALSE(APFloat::getZero(APFloat::IEEEsingle, false).isFiniteNonZero());
+ EXPECT_FALSE(APFloat::getZero(APFloat::IEEEsingle, true).isFiniteNonZero());
+
+ // Test +/- qNaN. +/- dont mean anything with qNaN but paranoia can't hurt in
+ // this instance.
+ EXPECT_FALSE(APFloat::getNaN(APFloat::IEEEsingle, false).isFiniteNonZero());
+ EXPECT_FALSE(APFloat::getNaN(APFloat::IEEEsingle, true).isFiniteNonZero());
+
+ // Test +/- sNaN. +/- dont mean anything with sNaN but paranoia can't hurt in
+ // this instance.
+ EXPECT_FALSE(APFloat::getSNaN(APFloat::IEEEsingle, false).isFiniteNonZero());
+ EXPECT_FALSE(APFloat::getSNaN(APFloat::IEEEsingle, true).isFiniteNonZero());
+}
+
}
OpenPOWER on IntegriCloud