tst-strtod-nan-sign-main.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Test strtod functions handle signs of NaNs (bug 23007).
  2. Copyright (C) 2018-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <math.h>
  16. #include <stdlib.h>
  17. #include <wchar.h>
  18. #include <stdlib/tst-strtod.h>
  19. #include <support/check.h>
  20. #define CONCAT_(X, Y) X ## Y
  21. #define CONCAT(X, Y) CONCAT_ (X, Y)
  22. #define FNX(FN) CONCAT (FNPFX, FN)
  23. #define TEST_STRTOD(FSUF, FTYPE, FTOSTR, LSUF, CSUF) \
  24. static int \
  25. test_strto ## FSUF (void) \
  26. { \
  27. FTYPE val_pos = FNX (FSUF) (L_("nan"), NULL); \
  28. FTYPE copy_pos = copysign ## CSUF (1, val_pos); \
  29. TEST_VERIFY (isnan (val_pos) && copy_pos == 1); \
  30. FTYPE val_neg = FNX (FSUF) (L_("-nan"), NULL); \
  31. FTYPE copy_neg = copysign ## CSUF (1, val_neg); \
  32. TEST_VERIFY (isnan (val_neg) && copy_neg == -1); \
  33. return 0; \
  34. }
  35. GEN_TEST_STRTOD_FOREACH (TEST_STRTOD)
  36. static int
  37. do_test (void)
  38. {
  39. return STRTOD_TEST_FOREACH (test_strto);
  40. }
  41. #include <support/test-driver.c>