root/maint/gnulib/tests/test-fmod-ieee.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. test_function

   1 /* Test of fmod*() function family.
   2    Copyright (C) 2012-2021 Free Software Foundation, Inc.
   3 
   4    This program is free software: you can redistribute it and/or modify
   5    it under the terms of the GNU General Public License as published by
   6    the Free Software Foundation; either version 3 of the License, or
   7    (at your option) any later version.
   8 
   9    This program is distributed in the hope that it will be useful,
  10    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12    GNU General Public License for more details.
  13 
  14    You should have received a copy of the GNU General Public License
  15    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
  16 
  17 static void
  18 test_function (void)
     /* [previous][next][first][last][top][bottom][index][help] */
  19 {
  20   /* [MX] shaded specification in POSIX.  */
  21 
  22   /* NaN.  */
  23   ASSERT (ISNAN (FMOD (NAN, L_(2.0))));
  24   ASSERT (ISNAN (FMOD (NAN, L_(0.0))));
  25   ASSERT (ISNAN (FMOD (L_(2.0), NAN)));
  26   ASSERT (ISNAN (FMOD (L_(0.0), NAN)));
  27   ASSERT (ISNAN (FMOD (NAN, NAN)));
  28 
  29   /* y is zero.  */
  30   ASSERT (ISNAN (FMOD (L_(2.0), L_(0.0))));
  31   ASSERT (ISNAN (FMOD (L_(2.0), MINUS_ZERO)));
  32   ASSERT (ISNAN (FMOD (INFINITY, L_(0.0))));
  33   ASSERT (ISNAN (FMOD (INFINITY, MINUS_ZERO)));
  34 
  35   /* x is infinite.  */
  36   ASSERT (ISNAN (FMOD (INFINITY, L_(2.0))));
  37   ASSERT (ISNAN (FMOD (INFINITY, - L_(2.0))));
  38 
  39   /* x is zero.  */
  40   {
  41     DOUBLE z = FMOD (L_(0.0), L_(2.0));
  42     ASSERT (z == L_(0.0));
  43     ASSERT (!signbit (z));
  44   }
  45   {
  46     DOUBLE z = FMOD (MINUS_ZERO, L_(2.0));
  47     ASSERT (z == L_(0.0));
  48     ASSERT (!!signbit (z) == !!signbit (MINUS_ZERO));
  49   }
  50   {
  51     DOUBLE z = FMOD (L_(0.0), - L_(2.0));
  52     ASSERT (z == L_(0.0));
  53     ASSERT (!signbit (z));
  54   }
  55   {
  56     DOUBLE z = FMOD (MINUS_ZERO, - L_(2.0));
  57     ASSERT (z == L_(0.0));
  58     ASSERT (!!signbit (z) == !!signbit (MINUS_ZERO));
  59   }
  60   {
  61     DOUBLE z = FMOD (L_(0.0), INFINITY);
  62     ASSERT (z == L_(0.0));
  63     ASSERT (!signbit (z));
  64   }
  65   {
  66     DOUBLE z = FMOD (MINUS_ZERO, INFINITY);
  67     ASSERT (z == L_(0.0));
  68     ASSERT (!!signbit (z) == !!signbit (MINUS_ZERO));
  69   }
  70   {
  71     DOUBLE z = FMOD (L_(0.0), - INFINITY);
  72     ASSERT (z == L_(0.0));
  73     ASSERT (!signbit (z));
  74   }
  75   {
  76     DOUBLE z = FMOD (MINUS_ZERO, - INFINITY);
  77     ASSERT (z == L_(0.0));
  78     ASSERT (!!signbit (z) == !!signbit (MINUS_ZERO));
  79   }
  80 
  81   /* y is infinite.  */
  82   {
  83     DOUBLE z = FMOD (L_(2.5), INFINITY);
  84     ASSERT (z == L_(2.5));
  85   }
  86   {
  87     DOUBLE z = FMOD (L_(2.5), - INFINITY);
  88     ASSERT (z == L_(2.5));
  89   }
  90   {
  91     DOUBLE z = FMOD (- L_(2.5), INFINITY);
  92     ASSERT (z == - L_(2.5));
  93   }
  94   {
  95     DOUBLE z = FMOD (- L_(2.5), - INFINITY);
  96     ASSERT (z == - L_(2.5));
  97   }
  98 }

/* [previous][next][first][last][top][bottom][index][help] */