test-math-isinff.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Test for bug 19439.
  2. Copyright (C) 2016 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Marek Polacek <polacek@redhat.com>, 2012.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library 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 GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #define _GNU_SOURCE 1
  17. #include <math.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. static int
  21. do_test (void)
  22. {
  23. /* Verify that isinff, isinfl, isnanf, and isnanlf are defined
  24. in the header under C++11 and can be called. Without the
  25. header fix this test will not compile. */
  26. if (isinff (1.0f)
  27. || !isinff (INFINITY)
  28. #ifndef NO_LONG_DOUBLE
  29. || isinfl (1.0L)
  30. || !isinfl (INFINITY)
  31. #endif
  32. || isnanf (2.0f)
  33. || !isnanf (NAN)
  34. #ifndef NO_LONG_DOUBLE
  35. || isnanl (2.0L)
  36. || !isnanl (NAN)
  37. #endif
  38. )
  39. {
  40. printf ("FAIL: Failed to call is* functions.\n");
  41. exit (1);
  42. }
  43. printf ("PASS: Able to call isinff, isinfl, isnanf, and isnanl.\n");
  44. exit (0);
  45. }
  46. #define TEST_FUNCTION do_test ()
  47. #include "../test-skeleton.c"