aboutsummaryrefslogtreecommitdiffstats
path: root/unittests/ADT
diff options
context:
space:
mode:
authorMichael Gottesman <mgottesman@apple.com>2013-05-29 23:58:29 +0000
committerMichael Gottesman <mgottesman@apple.com>2013-05-29 23:58:29 +0000
commit3e8d356b8103e1e3ddeb9b44d19f3a51af873261 (patch)
treec7680340ed7f42fdc5b490f726833b7549ca6b02 /unittests/ADT
parent6e0b2a0cb0d398f175a5294bf0ad5488c714e8c2 (diff)
downloadexternal_llvm-3e8d356b8103e1e3ddeb9b44d19f3a51af873261.zip
external_llvm-3e8d356b8103e1e3ddeb9b44d19f3a51af873261.tar.gz
external_llvm-3e8d356b8103e1e3ddeb9b44d19f3a51af873261.tar.bz2
Add a unittest for APFloat::getSmallest.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182894 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ADT')
-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 099f6db..4b51e85 100644
--- a/unittests/ADT/APFloatTest.cpp
+++ b/unittests/ADT/APFloatTest.cpp
@@ -794,6 +794,32 @@ TEST(APFloatTest, getLargest) {
EXPECT_EQ(1.7976931348623158e+308, APFloat::getLargest(APFloat::IEEEdouble).convertToDouble());
}
+TEST(APFloatTest, getSmallest) {
+ APFloat test = APFloat::getSmallest(APFloat::IEEEsingle, false);
+ APFloat expected = APFloat(APFloat::IEEEsingle, "0x0.000002p-126");
+ EXPECT_TRUE(!test.isNegative());
+ EXPECT_TRUE(test.isNormal());
+ EXPECT_TRUE(test.bitwiseIsEqual(expected));
+
+ test = APFloat::getSmallest(APFloat::IEEEsingle, true);
+ expected = APFloat(APFloat::IEEEsingle, "-0x0.000002p-126");
+ EXPECT_TRUE(test.isNegative());
+ EXPECT_TRUE(test.isNormal());
+ EXPECT_TRUE(test.bitwiseIsEqual(expected));
+
+ test = APFloat::getSmallest(APFloat::IEEEquad, false);
+ expected = APFloat(APFloat::IEEEquad, "0x0.0000000000000000000000000001p-16382");
+ EXPECT_TRUE(!test.isNegative());
+ EXPECT_TRUE(test.isNormal());
+ EXPECT_TRUE(test.bitwiseIsEqual(expected));
+
+ test = APFloat::getSmallest(APFloat::IEEEquad, true);
+ expected = APFloat(APFloat::IEEEquad, "-0x0.0000000000000000000000000001p-16382");
+ EXPECT_TRUE(test.isNegative());
+ EXPECT_TRUE(test.isNormal());
+ EXPECT_TRUE(test.bitwiseIsEqual(expected));
+}
+
TEST(APFloatTest, convert) {
bool losesInfo;
APFloat test(APFloat::IEEEdouble, "1.0");