]> granicus.if.org Git - check/commitdiff
Generate NAN and INFINITY in case they are not defined by the system headers
authorbel2125 <bel2125@gmail.com>
Sun, 27 Aug 2017 18:27:49 +0000 (20:27 +0200)
committerbel2125 <bel2125@gmail.com>
Sun, 27 Aug 2017 18:27:49 +0000 (20:27 +0200)
tests/check_check_sub.c

index dfde2f9c723d5dbe0630ae542d6a797c2817a3d0..c446f387e6471502590739cdfa2d798041824b4f 100644 (file)
 #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());
@@ -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");