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