root/maint/gnulib/tests/test-remainder-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 remainder*() 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 (REMAINDER (NAN, L_(2.0))));
  24   ASSERT (ISNAN (REMAINDER (NAN, L_(0.0))));
  25   ASSERT (ISNAN (REMAINDER (L_(2.0), NAN)));
  26   ASSERT (ISNAN (REMAINDER (L_(0.0), NAN)));
  27   ASSERT (ISNAN (REMAINDER (NAN, NAN)));
  28 
  29   /* y is zero.  */
  30   ASSERT (ISNAN (REMAINDER (L_(2.0), L_(0.0))));
  31   ASSERT (ISNAN (REMAINDER (L_(2.0), MINUS_ZERO)));
  32   ASSERT (ISNAN (REMAINDER (INFINITY, L_(0.0))));
  33   ASSERT (ISNAN (REMAINDER (INFINITY, MINUS_ZERO)));
  34 
  35   /* x is infinite.  */
  36   ASSERT (ISNAN (REMAINDER (INFINITY, L_(2.0))));
  37   ASSERT (ISNAN (REMAINDER (INFINITY, - L_(2.0))));
  38 
  39   /* The following tests originally applied to the FMOD function.
  40      They are not specified for the REMAINDER function by POSIX.  */
  41 
  42   /* x is zero.  */
  43   {
  44     DOUBLE z = REMAINDER (L_(0.0), L_(2.0));
  45     ASSERT (z == L_(0.0));
  46     ASSERT (!signbit (z));
  47   }
  48   {
  49     DOUBLE z = REMAINDER (MINUS_ZERO, L_(2.0));
  50     ASSERT (z == L_(0.0));
  51     ASSERT (!!signbit (z) == !!signbit (MINUS_ZERO));
  52   }
  53   {
  54     DOUBLE z = REMAINDER (L_(0.0), - L_(2.0));
  55     ASSERT (z == L_(0.0));
  56     ASSERT (!signbit (z));
  57   }
  58   {
  59     DOUBLE z = REMAINDER (MINUS_ZERO, - L_(2.0));
  60     ASSERT (z == L_(0.0));
  61     ASSERT (!!signbit (z) == !!signbit (MINUS_ZERO));
  62   }
  63 }

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