Skip to content

Commit

Permalink
Generate NAN and INFINITY in case they are not defined by the system …
Browse files Browse the repository at this point in the history
…headers
  • Loading branch information
bel2125 committed Aug 27, 2017
1 parent 20f4806 commit 2b406f1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/check_check_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
#include <check.h>
#include "check_check.h"

#if !defined(NAN)
/* According to POSIX, NAN and INFINITY are defined in math.h, see
* http://pubs.opengroup.org/onlinepubs/009695399/basedefs/math.h.html
* Hovever, older Visual Studio compilers do not define these values.
*/
double NAN;
#endif
#if !defined(INFINITY)
double INFINITY;
#endif

START_TEST(test_lno)
{
record_test_name(tcase_name());
Expand Down Expand Up @@ -2965,6 +2976,13 @@ Suite *make_sub_suite(void)
TCase *tc_exit_handlers;
#endif

#if !defined(NAN)
NAN /= NAN; /* division of 0 by 0 */
#endif
#if !defined(INFINITY)
INFINITY = 1.0 / INFINITY; /* division of 1 by 0 */
#endif

s = suite_create("Check Servant");

tc_simple = tcase_create("Simple Tests");
Expand Down

0 comments on commit 2b406f1

Please sign in to comment.