maint: update copyright
[gnulib.git] / tests / test-exp2.h
index f342603..9ea22fe 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of exp2*() function family.
-   Copyright (C) 2012 Free Software Foundation, Inc.
+   Copyright (C) 2012-2014 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -29,45 +29,41 @@ test_function (void)
     * (DOUBLE) (1U << ((MANT_DIG - 1 + 3) / 5))
     * (DOUBLE) (1U << ((MANT_DIG - 1 + 4) / 5));
 
-  /* Small integral arguments.  */
+  /* Integral arguments.  */
   {
     DOUBLE x = L_(0.0);
     DOUBLE y = EXP2 (x);
     ASSERT (y == L_(1.0));
   }
-  {
-    DOUBLE x = L_(1.0);
-    DOUBLE y = EXP2 (x);
-    ASSERT (y == L_(2.0));
-  }
-  {
-    DOUBLE x = L_(2.0);
-    DOUBLE y = EXP2 (x);
-    ASSERT (y == L_(4.0));
-  }
   /* <http://sourceware.org/bugzilla/show_bug.cgi?id=13824> */
-#if !(defined __linux__ && defined __sparc__)
+#if !(defined __linux__ && (defined __sparc__ || defined __powerpc__))
   {
-    DOUBLE x = L_(3.0);
-    DOUBLE y = EXP2 (x);
-    ASSERT (y == L_(8.0));
+    int e;
+    DOUBLE x;
+    DOUBLE y;
+    for (e = 0, x = L_(0.0), y = L_(1.0);
+         e <= MAX_EXP - 1;
+         e++, x = x + L_(1.0), y = y * L_(2.0))
+      {
+        /* Invariant: x = e, y = 2^e.  */
+        DOUBLE z = EXP2 (x);
+        ASSERT (z == y);
+      }
   }
   {
-    DOUBLE x = L_(4.0);
-    DOUBLE y = EXP2 (x);
-    ASSERT (y == L_(16.0));
+    int e;
+    DOUBLE x;
+    DOUBLE y;
+    for (e = 0, x = L_(0.0), y = L_(1.0);
+         e >= MIN_EXP - 1;
+         e--, x = x - L_(1.0), y = y * L_(0.5))
+      {
+        /* Invariant: x = e, y = 2^e.  */
+        DOUBLE z = EXP2 (x);
+        ASSERT (z == y);
+      }
   }
 #endif
-  {
-    DOUBLE x = - L_(1.0);
-    DOUBLE y = EXP2 (x);
-    ASSERT (y == L_(0.5));
-  }
-  {
-    DOUBLE x = - L_(2.0);
-    DOUBLE y = EXP2 (x);
-    ASSERT (y == L_(0.25));
-  }
 
   /* Randomized tests.  */
   {