math: print file:line in the error msg, fix nearbyint tests
[libc-test] / src / math / cosl.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 #include "crlibm/cos.h"
8 #include "ucb/cos.h"
9 #include "sanity/cos.h"
10
11 #elif LDBL_MANT_DIG == 64
12 #include "sanity/cosl.h"
13
14 #endif
15 };
16
17 int main(void)
18 {
19         long double y;
20         float d;
21         int e, i, err = 0;
22         struct l_l *p;
23
24         for (i = 0; i < sizeof t/sizeof *t; i++) {
25                 p = t + i;
26                 setupfenv(p->r);
27                 y = cosl(p->x);
28                 e = getexcept();
29                 if (!checkexcept(e, p->e, p->r)) {
30                         printf("%s:%d: bad fp exception: %s cosl(%La)=%La, want %s",
31                                 p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
32                         printf(" got %s\n", estr(e));
33                         err++;
34                 }
35                 d = ulperrl(y, p->y, p->dy);
36                 if (!checkulp(d, p->r)) {
37                         printf("%s:%d: %s cosl(%La) want %La got %La ulperr %.3f = %a + %a\n",
38                                 p->file, p->line, rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy);
39                         err++;
40                 }
41         }
42         return !!err;
43 }