math: print file:line in the error msg, fix nearbyint tests
[libc-test] / src / math / fabs.c
1 #include <stdint.h>
2 #include <stdio.h>
3 #include "util.h"
4
5 static struct d_d t[] = {
6 #include "ucb/fabs.h"
7 #include "sanity/fabs.h"
8
9 };
10
11 int main(void)
12 {
13         double y;
14         float d;
15         int e, i, err = 0;
16         struct d_d *p;
17
18         for (i = 0; i < sizeof t/sizeof *t; i++) {
19                 p = t + i;
20                 setupfenv(p->r);
21                 y = fabs(p->x);
22                 e = getexcept();
23                 if (!checkexcept(e, p->e, p->r)) {
24                         printf("%s:%d: bad fp exception: %s fabs(%a)=%a, want %s",
25                                 p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
26                         printf(" got %s\n", estr(e));
27                         err++;
28                 }
29                 d = ulperr(y, p->y, p->dy);
30                 if (!checkulp(d, p->r)) {
31                         printf("%s:%d: %s fabs(%a) want %a got %a ulperr %.3f = %a + %a\n",
32                                 p->file, p->line, rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy);
33                         err++;
34                 }
35         }
36         return !!err;
37 }