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