diff options
author | Michael Gottesman <mgottesman@apple.com> | 2013-05-30 00:18:47 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2013-05-30 00:18:47 +0000 |
commit | 999c693694f43b80b38b4827893d54e58cc3e0c6 (patch) | |
tree | 883e5711f483e3b546e68b5e02e3a80735ba346a /unittests | |
parent | 7d13d525bc9894a3be8e698002a01ce8ba5fc45d (diff) | |
download | llvm-999c693694f43b80b38b4827893d54e58cc3e0c6.tar.gz llvm-999c693694f43b80b38b4827893d54e58cc3e0c6.tar.bz2 llvm-999c693694f43b80b38b4827893d54e58cc3e0c6.tar.xz |
Added a unittest for APFloat::getSmallestNormalized.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182897 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/ADT/APFloatTest.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/unittests/ADT/APFloatTest.cpp b/unittests/ADT/APFloatTest.cpp index fce79941ff..87744d547f 100644 --- a/unittests/ADT/APFloatTest.cpp +++ b/unittests/ADT/APFloatTest.cpp @@ -824,6 +824,36 @@ TEST(APFloatTest, getSmallest) { EXPECT_TRUE(test.bitwiseIsEqual(expected)); } +TEST(APFloatTest, getSmallestNormalized) { + APFloat test = APFloat::getSmallestNormalized(APFloat::IEEEsingle, false); + APFloat expected = APFloat(APFloat::IEEEsingle, "0x1p-126"); + EXPECT_FALSE(test.isNegative()); + EXPECT_TRUE(test.isNormal()); + EXPECT_FALSE(test.isDenormal()); + EXPECT_TRUE(test.bitwiseIsEqual(expected)); + + test = APFloat::getSmallestNormalized(APFloat::IEEEsingle, true); + expected = APFloat(APFloat::IEEEsingle, "-0x1p-126"); + EXPECT_TRUE(test.isNegative()); + EXPECT_TRUE(test.isNormal()); + EXPECT_FALSE(test.isDenormal()); + EXPECT_TRUE(test.bitwiseIsEqual(expected)); + + test = APFloat::getSmallestNormalized(APFloat::IEEEquad, false); + expected = APFloat(APFloat::IEEEquad, "0x1p-16382"); + EXPECT_FALSE(test.isNegative()); + EXPECT_TRUE(test.isNormal()); + EXPECT_FALSE(test.isDenormal()); + EXPECT_TRUE(test.bitwiseIsEqual(expected)); + + test = APFloat::getSmallestNormalized(APFloat::IEEEquad, true); + expected = APFloat(APFloat::IEEEquad, "-0x1p-16382"); + EXPECT_TRUE(test.isNegative()); + EXPECT_TRUE(test.isNormal()); + EXPECT_FALSE(test.isDenormal()); + EXPECT_TRUE(test.bitwiseIsEqual(expected)); +} + TEST(APFloatTest, convert) { bool losesInfo; APFloat test(APFloat::IEEEdouble, "1.0"); |