add generated math tests
[libc-test] / src / math / floorl.c
1 #include <stdint.h>
2 #include <stdio.h>
3 #include "util.h"
4
5 static struct l_l t[] = {
6 #if LDBL_MANT_DIG == 53
7 D
8 #include "sanity/floorl.h"
9 #elif LDBL_MANT_DIG == 64
10
11 #include "sanity/floorl.h"
12 #endif
13 };
14
15 int main(void)
16 {
17         long double y;
18         float d;
19         int e, i, err = 0;
20         struct l_l *p;
21
22         for (i = 0; i < sizeof t/sizeof *t; i++) {
23                 p = t + i;
24                 setupfenv(p->r);
25                 y = floorl(p->x);
26                 e = getexcept();
27                 if (!checkexcept(e, p->e, p->r)) {
28                         printf("%s floorl(%La)==%La except: want %s", rstr(p->r), p->x, p->y, 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)) {
34                         printf("%s floorl(%La) want %La got %La ulperr %.3f = %a + %a\n",
35                                 rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy);
36                         err++;
37                 }
38         }
39         return !!err;
40 }