t_isnan.c revision 272343
1/* $NetBSD: t_isnan.c,v 1.4 2014/02/09 21:26:07 jmmv Exp $ */ 2 3/* 4 * This file is in the Public Domain. 5 * 6 * The nan test is blatently copied by Simon Burge from the infinity 7 * test by Ben Harris. 8 */ 9 10#include <sys/param.h> 11 12#include <atf-c.h> 13#include <atf-c/config.h> 14 15#include <math.h> 16#include <string.h> 17 18ATF_TC(isnan_basic); 19ATF_TC_HEAD(isnan_basic, tc) 20{ 21 atf_tc_set_md_var(tc, "descr", "Verify that isnan(3) works"); 22} 23 24ATF_TC_BODY(isnan_basic, tc) 25{ 26#if defined(__m68k__) 27 atf_tc_skip("Test not applicable on " MACHINE_ARCH); 28#endif 29 30#ifdef NAN 31 /* NAN is meant to be a (float)NaN. */ 32 ATF_CHECK(isnan(NAN) != 0); 33 ATF_CHECK(isnan((double)NAN) != 0); 34#else 35 atf_tc_skip("Test not applicable"); 36#endif 37} 38 39ATF_TC(isinf_basic); 40ATF_TC_HEAD(isinf_basic, tc) 41{ 42 atf_tc_set_md_var(tc, "descr", "Verify that isinf(3) works"); 43} 44 45ATF_TC_BODY(isinf_basic, tc) 46{ 47#if defined(__m68k__) 48 atf_tc_skip("Test not applicable on " MACHINE_ARCH); 49#endif 50 51 /* HUGE_VAL is meant to be an infinity. */ 52 ATF_CHECK(isinf(HUGE_VAL) != 0); 53 54 /* HUGE_VALF is the float analog of HUGE_VAL. */ 55 ATF_CHECK(isinf(HUGE_VALF) != 0); 56 57 /* HUGE_VALL is the long double analog of HUGE_VAL. */ 58 ATF_CHECK(isinf(HUGE_VALL) != 0); 59} 60 61ATF_TP_ADD_TCS(tp) 62{ 63 ATF_TP_ADD_TC(tp, isnan_basic); 64 ATF_TP_ADD_TC(tp, isinf_basic); 65 66 return atf_no_error(); 67} 68