add generated math tests
[libc-test.git] / src / math / tanh.c
blob54a6e80aaccc3dc23328122451f2eadadf1e8ed2
1 #include <stdint.h>
2 #include <stdio.h>
3 #include "util.h"
5 static struct d_d t[] = {
7 #include "ucb/tanh.h"
8 #include "sanity/tanh.h"
9 };
11 int main(void)
13 double y;
14 float d;
15 int e, i, err = 0;
16 struct d_d *p;
18 for (i = 0; i < sizeof t/sizeof *t; i++) {
19 p = t + i;
20 setupfenv(p->r);
21 y = tanh(p->x);
22 e = getexcept();
23 if (!checkexcept(e, p->e, p->r)) {
24 printf("%s tanh(%a)==%a except: want %s", rstr(p->r), p->x, p->y, estr(p->e));
25 printf(" got %s\n", estr(e));
26 err++;
28 d = ulperr(y, p->y, p->dy);
29 if (!checkulp(d, p->r)) {
30 printf("%s tanh(%a) want %a got %a ulperr %.3f = %a + %a\n",
31 rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy);
32 err++;
35 return !!err;