From bff1b480953c080e45f31bbaaec96cc1539acc0d Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Thu, 30 May 2013 00:18:47 +0000 Subject: [PATCH] Added a unittest for APFloat::getSmallestNormalized. llvm-svn: 182897 --- unittests/ADT/APFloatTest.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/unittests/ADT/APFloatTest.cpp b/unittests/ADT/APFloatTest.cpp index fce79941ff2..87744d547f5 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");