[llvm] r182894 - Add a unittest for APFloat::getSmallest.
Michael Gottesman
mgottesman at apple.com
Wed May 29 16:58:29 PDT 2013
Author: mgottesman
Date: Wed May 29 18:58:29 2013
New Revision: 182894
URL: http://llvm.org/viewvc/llvm-project?rev=182894&view=rev
Log:
Add a unittest for APFloat::getSmallest.
Modified:
llvm/trunk/unittests/ADT/APFloatTest.cpp
Modified: llvm/trunk/unittests/ADT/APFloatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/APFloatTest.cpp?rev=182894&r1=182893&r2=182894&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/APFloatTest.cpp (original)
+++ llvm/trunk/unittests/ADT/APFloatTest.cpp Wed May 29 18:58:29 2013
@@ -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");
More information about the llvm-commits
mailing list