maint: update copyright
[gnulib.git] / tests / test-ldexp.h
index 76a095e..00c4446 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of ldexp*() function family.
-   Copyright (C) 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007-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
@@ -114,4 +114,17 @@ test_function (void)
       y = LDEXP (x, 0); ASSERT (y == x);
       y = LDEXP (x, 5); ASSERT (y == x * L_(32.0));
     }
+
+  /* Randomized tests.  */
+  for (i = 0; i < SIZEOF (RANDOM); i++)
+    {
+      int u, v;
+
+      x = L_(20.0) * RANDOM[i] - L_(10.0); /* -10.0 <= x <= 10.0 */
+      /* LDEXP only does rounding when it returns a denormalized number
+         or there is underflow.  It doesn't happen here.  */
+      for (u = -10; u <= 10; u++)
+        for (v = -10; v <= 10; v++)
+          ASSERT (LDEXP (x, u + v) == LDEXP (LDEXP (x, u), v));
+    }
 }