Remove unused debug info constants.
[oota-llvm.git] / unittests / ADT / APFloatTest.cpp
index bc11dab663fdf8ba0164cc8c8079d8269884d4ec..a86be5af375043fcdcb48a5de5ed5771e85777e8 100644 (file)
@@ -476,6 +476,28 @@ TEST(APFloatTest, FMA) {
   }
 }
 
+TEST(APFloatTest, MinNum) {
+  APFloat f1(1.0);
+  APFloat f2(2.0);
+  APFloat nan = APFloat::getNaN(APFloat::IEEEdouble);
+
+  EXPECT_EQ(1.0, minnum(f1, f2).convertToDouble());
+  EXPECT_EQ(1.0, minnum(f2, f1).convertToDouble());
+  EXPECT_EQ(1.0, minnum(f1, nan).convertToDouble());
+  EXPECT_EQ(1.0, minnum(nan, f1).convertToDouble());
+}
+
+TEST(APFloatTest, MaxNum) {
+  APFloat f1(1.0);
+  APFloat f2(2.0);
+  APFloat nan = APFloat::getNaN(APFloat::IEEEdouble);
+
+  EXPECT_EQ(2.0, maxnum(f1, f2).convertToDouble());
+  EXPECT_EQ(2.0, maxnum(f2, f1).convertToDouble());
+  EXPECT_EQ(1.0, maxnum(f1, nan).convertToDouble());
+  EXPECT_EQ(1.0, minnum(nan, f1).convertToDouble());
+}
+
 TEST(APFloatTest, Denormal) {
   APFloat::roundingMode rdmd = APFloat::rmNearestTiesToEven;
 
@@ -2692,55 +2714,71 @@ TEST(APFloatTest, operatorOverloads) {
   EXPECT_TRUE(One.bitwiseIsEqual(Two / Two));
 }
 
-TEST(APFloatTest, logb) {
-  EXPECT_TRUE(
-      APFloat(APFloat::IEEEsingle, "0x0p+0")
-          .bitwiseIsEqual(logb(APFloat(APFloat::IEEEsingle, "0x1p+0"))));
-  EXPECT_TRUE(
-      APFloat(APFloat::IEEEsingle, "0x0p+0")
-          .bitwiseIsEqual(logb(APFloat(APFloat::IEEEsingle, "-0x1p+0"))));
-  EXPECT_TRUE(
-      APFloat(APFloat::IEEEsingle, "0x2Ap+0")
-          .bitwiseIsEqual(logb(APFloat(APFloat::IEEEsingle, "0x1p+42"))));
-  EXPECT_TRUE(
-      APFloat(APFloat::IEEEsingle, "-0x2Ap+0")
-          .bitwiseIsEqual(logb(APFloat(APFloat::IEEEsingle, "0x1p-42"))));
-
+TEST(APFloatTest, abs) {
   APFloat PInf = APFloat::getInf(APFloat::IEEEsingle, false);
   APFloat MInf = APFloat::getInf(APFloat::IEEEsingle, true);
   APFloat PZero = APFloat::getZero(APFloat::IEEEsingle, false);
   APFloat MZero = APFloat::getZero(APFloat::IEEEsingle, true);
-  APFloat QNaN = APFloat::getNaN(APFloat::IEEEsingle, false);
-  APFloat SNaN = APFloat::getSNaN(APFloat::IEEEsingle, false);
-
-  EXPECT_TRUE(PInf.bitwiseIsEqual(logb(PInf)));
-  EXPECT_TRUE(PInf.bitwiseIsEqual(logb(MInf)));
-  EXPECT_TRUE(PZero.bitwiseIsEqual(logb(PZero)));
-  EXPECT_TRUE(MZero.bitwiseIsEqual(logb(MZero)));
-  EXPECT_TRUE(QNaN.bitwiseIsEqual(logb(QNaN)));
-  EXPECT_TRUE(SNaN.bitwiseIsEqual(logb(SNaN)));
-
+  APFloat PQNaN = APFloat::getNaN(APFloat::IEEEsingle, false);
+  APFloat MQNaN = APFloat::getNaN(APFloat::IEEEsingle, true);
+  APFloat PSNaN = APFloat::getSNaN(APFloat::IEEEsingle, false);
+  APFloat MSNaN = APFloat::getSNaN(APFloat::IEEEsingle, true);
+  APFloat PNormalValue = APFloat(APFloat::IEEEsingle, "0x1p+0");
+  APFloat MNormalValue = APFloat(APFloat::IEEEsingle, "-0x1p+0");
   APFloat PLargestValue = APFloat::getLargest(APFloat::IEEEsingle, false);
   APFloat MLargestValue = APFloat::getLargest(APFloat::IEEEsingle, true);
   APFloat PSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle, false);
   APFloat MSmallestValue = APFloat::getSmallest(APFloat::IEEEsingle, true);
   APFloat PSmallestNormalized =
-      APFloat::getSmallestNormalized(APFloat::IEEEsingle, false);
+    APFloat::getSmallestNormalized(APFloat::IEEEsingle, false);
   APFloat MSmallestNormalized =
-      APFloat::getSmallestNormalized(APFloat::IEEEsingle, true);
+    APFloat::getSmallestNormalized(APFloat::IEEEsingle, true);
 
-  EXPECT_TRUE(
-      APFloat(APFloat::IEEEsingle, "0x7Fp+0").bitwiseIsEqual(logb(PLargestValue)));
-  EXPECT_TRUE(
-      APFloat(APFloat::IEEEsingle, "0x7Fp+0").bitwiseIsEqual(logb(MLargestValue)));
-  EXPECT_TRUE(
-      APFloat(APFloat::IEEEsingle, "-0x7Ep+0").bitwiseIsEqual(logb(PSmallestValue)));
-  EXPECT_TRUE(
-      APFloat(APFloat::IEEEsingle, "-0x7Ep+0").bitwiseIsEqual(logb(MSmallestValue)));
-  EXPECT_TRUE(APFloat(APFloat::IEEEsingle, "-0x7Ep+0")
-                  .bitwiseIsEqual(logb(PSmallestNormalized)));
-  EXPECT_TRUE(APFloat(APFloat::IEEEsingle, "-0x7Ep+0")
-                  .bitwiseIsEqual(logb(MSmallestNormalized)));
+  EXPECT_TRUE(PInf.bitwiseIsEqual(abs(PInf)));
+  EXPECT_TRUE(PInf.bitwiseIsEqual(abs(MInf)));
+  EXPECT_TRUE(PZero.bitwiseIsEqual(abs(PZero)));
+  EXPECT_TRUE(PZero.bitwiseIsEqual(abs(MZero)));
+  EXPECT_TRUE(PQNaN.bitwiseIsEqual(abs(PQNaN)));
+  EXPECT_TRUE(PQNaN.bitwiseIsEqual(abs(MQNaN)));
+  EXPECT_TRUE(PSNaN.bitwiseIsEqual(abs(PSNaN)));
+  EXPECT_TRUE(PSNaN.bitwiseIsEqual(abs(MSNaN)));
+  EXPECT_TRUE(PNormalValue.bitwiseIsEqual(abs(PNormalValue)));
+  EXPECT_TRUE(PNormalValue.bitwiseIsEqual(abs(MNormalValue)));
+  EXPECT_TRUE(PLargestValue.bitwiseIsEqual(abs(PLargestValue)));
+  EXPECT_TRUE(PLargestValue.bitwiseIsEqual(abs(MLargestValue)));
+  EXPECT_TRUE(PSmallestValue.bitwiseIsEqual(abs(PSmallestValue)));
+  EXPECT_TRUE(PSmallestValue.bitwiseIsEqual(abs(MSmallestValue)));
+  EXPECT_TRUE(PSmallestNormalized.bitwiseIsEqual(abs(PSmallestNormalized)));
+  EXPECT_TRUE(PSmallestNormalized.bitwiseIsEqual(abs(MSmallestNormalized)));
+}
+
+TEST(APFloatTest, ilogb) {
+  EXPECT_EQ(0, ilogb(APFloat(APFloat::IEEEsingle, "0x1p+0")));
+  EXPECT_EQ(0, ilogb(APFloat(APFloat::IEEEsingle, "-0x1p+0")));
+  EXPECT_EQ(42, ilogb(APFloat(APFloat::IEEEsingle, "0x1p+42")));
+  EXPECT_EQ(-42, ilogb(APFloat(APFloat::IEEEsingle, "0x1p-42")));
+
+  EXPECT_EQ(APFloat::IEK_Inf,
+            ilogb(APFloat::getInf(APFloat::IEEEsingle, false)));
+  EXPECT_EQ(APFloat::IEK_Inf,
+            ilogb(APFloat::getInf(APFloat::IEEEsingle, true)));
+  EXPECT_EQ(APFloat::IEK_Zero,
+            ilogb(APFloat::getZero(APFloat::IEEEsingle, false)));
+  EXPECT_EQ(APFloat::IEK_Zero,
+            ilogb(APFloat::getZero(APFloat::IEEEsingle, true)));
+  EXPECT_EQ(APFloat::IEK_NaN,
+            ilogb(APFloat::getNaN(APFloat::IEEEsingle, false)));
+  EXPECT_EQ(APFloat::IEK_NaN,
+            ilogb(APFloat::getSNaN(APFloat::IEEEsingle, false)));
+
+  EXPECT_EQ(127, ilogb(APFloat::getLargest(APFloat::IEEEsingle, false)));
+  EXPECT_EQ(127, ilogb(APFloat::getLargest(APFloat::IEEEsingle, true)));
+  EXPECT_EQ(-126, ilogb(APFloat::getSmallest(APFloat::IEEEsingle, false)));
+  EXPECT_EQ(-126, ilogb(APFloat::getSmallest(APFloat::IEEEsingle, true)));
+  EXPECT_EQ(-126,
+            ilogb(APFloat::getSmallestNormalized(APFloat::IEEEsingle, false)));
+  EXPECT_EQ(-126,
+            ilogb(APFloat::getSmallestNormalized(APFloat::IEEEsingle, true)));
 }
 
 TEST(APFloatTest, scalbn) {