math: add some float f(float,int) and some float f(float,int*) tests
[libc-test] / src / math / scalbn.c
diff --git a/src/math/scalbn.c b/src/math/scalbn.c
new file mode 100644 (file)
index 0000000..317d082
--- /dev/null
@@ -0,0 +1,36 @@
+#include <stdint.h>
+#include <stdio.h>
+#include "util.h"
+
+static struct di_d t[] = {
+#include "sanity/scalbn.h"
+
+};
+
+int main(void)
+{
+       double y;
+       float d;
+       int e, i, err = 0;
+       struct di_d *p;
+
+       for (i = 0; i < sizeof t/sizeof *t; i++) {
+               p = t + i;
+               setupfenv(p->r);
+               y = scalbn(p->x, p->i);
+               e = getexcept();
+               if (!checkexcept(e, p->e, p->r)) {
+                       printf("%s:%d: bad fp exception: %s scalbn(%a, %lld)=%a, want %s",
+                               p->file, p->line, rstr(p->r), p->x, p->i, p->y, estr(p->e));
+                       printf(" got %s\n", estr(e));
+                       err++;
+               }
+               d = ulperr(y, p->y, p->dy);
+               if (!checkulp(d, p->r)) {
+                       printf("%s:%d: %s scalbn(%a, %lld) want %a got %a, ulperr %.3f = %a + %a\n",
+                               p->file, p->line, rstr(p->r), p->x, p->i, p->y, y, d, d-p->dy, p->dy);
+                       err++;
+               }
+       }
+       return !!err;
+}