xref: /third_party/musl/libc-test/src/math/erfcl.c (revision 570af302)
1#include <stdint.h>
2#include <stdio.h>
3#include "mtest.h"
4
5static struct l_l t[] = {
6#if LDBL_MANT_DIG == 53
7#include "sanity/erfc.h"
8#include "special/erfc.h"
9
10#elif LDBL_MANT_DIG == 64
11#include "sanity/erfcl.h"
12#include "special/erfcl.h"
13
14#elif LDBL_MANT_DIG == 113
15#ifdef LD128_ENABLE
16#include "ld128/erfcl.h"
17#endif
18
19#endif
20};
21
22int main(void)
23{
24	#pragma STDC FENV_ACCESS ON
25	long double y;
26	float d;
27	int e, i, err = 0;
28	struct l_l *p;
29
30	for (i = 0; i < sizeof t/sizeof *t; i++) {
31		p = t + i;
32
33		if (p->r < 0)
34			continue;
35		fesetround(p->r);
36		feclearexcept(FE_ALL_EXCEPT);
37		y = erfcl(p->x);
38		e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
39
40		if (!checkexcept(e, p->e, p->r)) {
41			printf("%s:%d: bad fp exception: %s erfcl(%La)=%La, want %s",
42				p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
43			printf(" got %s\n", estr(e));
44			err++;
45		}
46		d = ulperrl(y, p->y, p->dy);
47		if (!checkulp(d, p->r)) {
48			printf("%s:%d: %s erfcl(%La) want %La got %La ulperr %.3f = %a + %a\n",
49				p->file, p->line, rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy);
50			err++;
51		}
52	}
53	return !!err;
54}
55