Added a unittest for APFloat::getSmallestNormalized.

llvm-svn: 182897
This commit is contained in:
Michael Gottesman 2013-05-30 00:18:47 +00:00
parent 09f3ab01b8
commit bff1b48095

View File

@ -824,6 +824,36 @@ TEST(APFloatTest, getSmallest) {
EXPECT_TRUE(test.bitwiseIsEqual(expected)); 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) { TEST(APFloatTest, convert) {
bool losesInfo; bool losesInfo;
APFloat test(APFloat::IEEEdouble, "1.0"); APFloat test(APFloat::IEEEdouble, "1.0");