]>
Commit | Line | Data |
---|---|---|
9c06eb66 UD |
1 | #include <stdio.h> |
2 | #include <string.h> | |
3 | ||
2d1e6277 UD |
4 | struct |
5 | { | |
6 | long double val; | |
7 | const char str[4][7]; | |
8 | } tests[] = | |
9 | { | |
10 | { 0x0.FFFFp+0L, { "0X1P+0", "0X2P-1", "0X4P-2", "0X8P-3" } }, | |
11 | { 0x0.FFFFp+1L, { "0X1P+1", "0X2P+0", "0X4P-1", "0X8P-2" } }, | |
12 | { 0x0.FFFFp+2L, { "0X1P+2", "0X2P+1", "0X4P+0", "0X8P-1" } }, | |
13 | { 0x0.FFFFp+3L, { "0X1P+3", "0X2P+2", "0X4P+1", "0X8P+0" } } | |
14 | }; | |
15 | ||
9c06eb66 UD |
16 | static int |
17 | do_test (void) | |
18 | { | |
19 | char buf[100]; | |
2d1e6277 UD |
20 | int ret = 0; |
21 | ||
22 | for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i) | |
9c84384c | 23 | { |
2d1e6277 UD |
24 | snprintf (buf, sizeof (buf), "%.0LA", tests[i].val); |
25 | ||
26 | size_t j; | |
27 | for (j = 0; j < 4; ++j) | |
28 | if (strcmp (buf, tests[i].str[j]) == 0) | |
29 | break; | |
9c06eb66 | 30 | |
2d1e6277 UD |
31 | if (j == 4) |
32 | { | |
33 | printf ("%zd: got \"%s\", expected \"%s\" or equivalent\n", | |
34 | i, buf, tests[i].str[0]); | |
35 | ret = 1; | |
36 | } | |
9c06eb66 UD |
37 | } |
38 | ||
2d1e6277 | 39 | return ret; |
9c06eb66 UD |
40 | } |
41 | ||
42 | #define TEST_FUNCTION do_test () | |
43 | #include "../test-skeleton.c" |