blob: b595459a37496424da7d9da0a23021d1ca886793 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#include <math.h>
2#include <float.h>
3#include <stdlib.h>
4#include <stdint.h>
5#include <stdio.h>
6
7#define check_d1(func, param, expected) \
8do { \
9 int err; hex_union ur; hex_union up; \
10 double result = func(param); up.f = param; ur.f = result; \
11 errors += (err = (result != (expected))); \
12 err \
13 ? printf("FAIL: %s(%g/"HEXFMT")=%g/"HEXFMT" (expected %g)\n", \
14 #func, (double)(param), (long long)up.hex, result, (long long)ur.hex, (double)(expected)) \
15 : printf("PASS: %s(%g)=%g\n", #func, (double)(param), result); \
16} while (0)
17
18#define HEXFMT "%08llx"
19typedef union {
20 double f;
21 uint64_t hex;
22} hex_union;
23double result;
24
25int errors = 0;
26
27int main(void)
28{
29 check_d1(rint, 0.6, 1.0);
30
31 printf("Errors: %d\n", errors);
32 return errors;
33}