math: add some float f(float,int) and some float f(float,int*) tests
[libc-test] / src / math / gen / template / l_li.c
1 #include <stdint.h>
2 #include <stdio.h>
3 #include "util.h"
4
5 static struct l_li t[] = {
6 #if LDBL_MANT_DIG == 53
7 DHEADERS
8 #elif LDBL_MANT_DIG == 64
9 HEADERS
10 #endif
11 };
12
13 int main(void)
14 {
15         int yi;
16         long double y;
17         float d;
18         int e, i, err = 0;
19         struct l_li *p;
20
21         for (i = 0; i < sizeof t/sizeof *t; i++) {
22                 p = t + i;
23                 setupfenv(p->r);
24                 y = ___(p->x, &yi);
25                 e = getexcept();
26                 if (!checkexcept(e, p->e, p->r)) {
27                         printf("%s:%d: bad fp exception: %s ___(%La)=%La,%lld, want %s",
28                                 p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e));
29                         printf(" got %s\n", estr(e));
30                         err++;
31                 }
32                 d = ulperrl(y, p->y, p->dy);
33                 if (!checkulp(d, p->r) || yi != p->i) {
34                         printf("%s:%d: %s ___(%La) want %La,%lld got %La,%d ulperr %.3f = %a + %a\n",
35                                 p->file, p->line, rstr(p->r), p->x, p->y, p->i, y, yi, d, d-p->dy, p->dy);
36                         err++;
37                 }
38         }
39         return !!err;
40 }