Added a unittest for APFloat::getSmallestNormalized.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182897 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Michael Gottesman 2013-05-30 00:18:47 +00:00
parent 7d13d525bc
commit 999c693694

View File

@ -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");