1*0a6a1f1dSLionel Sambuc /* $NetBSD: t_isnan.c,v 1.5 2014/11/04 00:20:19 justin Exp $ */
211be35a1SLionel Sambuc
311be35a1SLionel Sambuc /*
411be35a1SLionel Sambuc * This file is in the Public Domain.
511be35a1SLionel Sambuc *
611be35a1SLionel Sambuc * The nan test is blatently copied by Simon Burge from the infinity
711be35a1SLionel Sambuc * test by Ben Harris.
811be35a1SLionel Sambuc */
911be35a1SLionel Sambuc
10*0a6a1f1dSLionel Sambuc #include <sys/param.h>
11*0a6a1f1dSLionel Sambuc
1211be35a1SLionel Sambuc #include <atf-c.h>
1311be35a1SLionel Sambuc
1411be35a1SLionel Sambuc #include <math.h>
1511be35a1SLionel Sambuc #include <string.h>
1611be35a1SLionel Sambuc
1711be35a1SLionel Sambuc ATF_TC(isnan_basic);
ATF_TC_HEAD(isnan_basic,tc)1811be35a1SLionel Sambuc ATF_TC_HEAD(isnan_basic, tc)
1911be35a1SLionel Sambuc {
2011be35a1SLionel Sambuc atf_tc_set_md_var(tc, "descr", "Verify that isnan(3) works");
2111be35a1SLionel Sambuc }
2211be35a1SLionel Sambuc
ATF_TC_BODY(isnan_basic,tc)2311be35a1SLionel Sambuc ATF_TC_BODY(isnan_basic, tc)
2411be35a1SLionel Sambuc {
25*0a6a1f1dSLionel Sambuc #if defined(__m68k__)
26*0a6a1f1dSLionel Sambuc atf_tc_skip("Test not applicable on " MACHINE_ARCH);
27*0a6a1f1dSLionel Sambuc #endif
28*0a6a1f1dSLionel Sambuc
2984d9c625SLionel Sambuc #ifdef NAN
3011be35a1SLionel Sambuc /* NAN is meant to be a (float)NaN. */
3111be35a1SLionel Sambuc ATF_CHECK(isnan(NAN) != 0);
3211be35a1SLionel Sambuc ATF_CHECK(isnan((double)NAN) != 0);
3384d9c625SLionel Sambuc #else
3484d9c625SLionel Sambuc atf_tc_skip("Test not applicable");
3584d9c625SLionel Sambuc #endif
3611be35a1SLionel Sambuc }
3711be35a1SLionel Sambuc
3811be35a1SLionel Sambuc ATF_TC(isinf_basic);
ATF_TC_HEAD(isinf_basic,tc)3911be35a1SLionel Sambuc ATF_TC_HEAD(isinf_basic, tc)
4011be35a1SLionel Sambuc {
4111be35a1SLionel Sambuc atf_tc_set_md_var(tc, "descr", "Verify that isinf(3) works");
4211be35a1SLionel Sambuc }
4311be35a1SLionel Sambuc
ATF_TC_BODY(isinf_basic,tc)4411be35a1SLionel Sambuc ATF_TC_BODY(isinf_basic, tc)
4511be35a1SLionel Sambuc {
46*0a6a1f1dSLionel Sambuc #if defined(__m68k__)
47*0a6a1f1dSLionel Sambuc atf_tc_skip("Test not applicable on " MACHINE_ARCH);
48*0a6a1f1dSLionel Sambuc #endif
4911be35a1SLionel Sambuc
5011be35a1SLionel Sambuc /* HUGE_VAL is meant to be an infinity. */
5111be35a1SLionel Sambuc ATF_CHECK(isinf(HUGE_VAL) != 0);
5211be35a1SLionel Sambuc
5311be35a1SLionel Sambuc /* HUGE_VALF is the float analog of HUGE_VAL. */
5411be35a1SLionel Sambuc ATF_CHECK(isinf(HUGE_VALF) != 0);
5511be35a1SLionel Sambuc
5611be35a1SLionel Sambuc /* HUGE_VALL is the long double analog of HUGE_VAL. */
5711be35a1SLionel Sambuc ATF_CHECK(isinf(HUGE_VALL) != 0);
5811be35a1SLionel Sambuc }
5911be35a1SLionel Sambuc
ATF_TP_ADD_TCS(tp)6011be35a1SLionel Sambuc ATF_TP_ADD_TCS(tp)
6111be35a1SLionel Sambuc {
6211be35a1SLionel Sambuc ATF_TP_ADD_TC(tp, isnan_basic);
6311be35a1SLionel Sambuc ATF_TP_ADD_TC(tp, isinf_basic);
6411be35a1SLionel Sambuc
6511be35a1SLionel Sambuc return atf_no_error();
6611be35a1SLionel Sambuc }
67