test-signgam-finite.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* Test lgamma functions set signgam for -ffinite-math-only (bug 19211).
  2. Copyright (C) 2015-2016 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 <stdio.h>
  17. #define RUN_TESTS(FUNC, TYPE) \
  18. do \
  19. { \
  20. volatile TYPE a, b, c __attribute__ ((unused)); \
  21. a = 0.5; \
  22. b = -0.5; \
  23. signgam = 123; \
  24. c = FUNC (a); \
  25. if (signgam == 1) \
  26. puts ("PASS: " #FUNC " (0.5) setting signgam"); \
  27. else \
  28. { \
  29. puts ("FAIL: " #FUNC " (0.5) setting signgam"); \
  30. result = 1; \
  31. } \
  32. signgam = 123; \
  33. c = FUNC (b); \
  34. if (signgam == -1) \
  35. puts ("PASS: " #FUNC " (-0.5) setting signgam"); \
  36. else \
  37. { \
  38. puts ("FAIL: " #FUNC " (-0.5) setting signgam"); \
  39. result = 1; \
  40. } \
  41. } \
  42. while (0)
  43. static int
  44. do_test (void)
  45. {
  46. int result = 0;
  47. RUN_TESTS (lgammaf, float);
  48. RUN_TESTS (gammaf, float);
  49. RUN_TESTS (lgamma, double);
  50. RUN_TESTS (gamma, double);
  51. #ifndef NO_LONG_DOUBLE
  52. RUN_TESTS (lgammal, long double);
  53. RUN_TESTS (gammal, long double);
  54. #endif
  55. return result;
  56. }
  57. #define TEST_FUNCTION do_test ()
  58. #include "../test-skeleton.c"