t_isnan.c revision 1.6
1/* $NetBSD: t_isnan.c,v 1.6 2025/04/07 01:54:22 riastradh 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 14#include <math.h> 15#include <string.h> 16 17ATF_TC(isnan_basic); 18ATF_TC_HEAD(isnan_basic, tc) 19{ 20 atf_tc_set_md_var(tc, "descr", "Verify that isnan(3) works"); 21} 22 23ATF_TC_BODY(isnan_basic, tc) 24{ 25 26#ifdef NAN 27 /* NAN is meant to be a (float)NaN. */ 28 ATF_CHECK(isnan(NAN) != 0); 29 ATF_CHECK(isnan((double)NAN) != 0); 30#else 31 atf_tc_skip("No NaN on this architecture"); 32#endif 33} 34 35ATF_TC(isinf_basic); 36ATF_TC_HEAD(isinf_basic, tc) 37{ 38 atf_tc_set_md_var(tc, "descr", "Verify that isinf(3) works"); 39} 40 41ATF_TC_BODY(isinf_basic, tc) 42{ 43#ifdef __vax__ 44 atf_tc_skip("No infinity on this architecture"); 45#endif 46 47 /* HUGE_VAL is meant to be an infinity. */ 48 ATF_CHECK(isinf(HUGE_VAL) != 0); 49 50 /* HUGE_VALF is the float analog of HUGE_VAL. */ 51 ATF_CHECK(isinf(HUGE_VALF) != 0); 52 53 /* HUGE_VALL is the long double analog of HUGE_VAL. */ 54 ATF_CHECK(isinf(HUGE_VALL) != 0); 55} 56 57ATF_TP_ADD_TCS(tp) 58{ 59 ATF_TP_ADD_TC(tp, isnan_basic); 60 ATF_TP_ADD_TC(tp, isinf_basic); 61 62 return atf_no_error(); 63} 64