1 /* Test program for %a printf formats. */
13 static const struct testcase testcases
[] =
15 { 0x0.0030p
+0, "%a", "0x1.8p-11" },
16 { 0x0.0040p
+0, "%a", "0x1p-10" },
17 { 0x0.0030p
+0, "%040a", "0x00000000000000000000000000000001.8p-11" },
18 { 0x0.0040p
+0, "%040a", "0x0000000000000000000000000000000001p-10" },
19 { 0x0.0040p
+0, "%40a", " 0x1p-10" },
20 { 0x0.0040p
+0, "%#40a", " 0x1.p-10" },
21 { 0x0.0040p
+0, "%-40a", "0x1p-10 " },
22 { 0x0.0040p
+0, "%#-40a", "0x1.p-10 " },
23 { 0x0.0030p
+0, "%040e", "00000000000000000000000000007.324219e-04" },
24 { 0x0.0040p
+0, "%040e", "00000000000000000000000000009.765625e-04" },
29 do_test (int argc
, char **argv
)
31 const struct testcase
*t
;
35 t
< &testcases
[sizeof testcases
/ sizeof testcases
[0]];
39 int n
= snprintf (buf
, sizeof buf
, t
->fmt
, t
->value
);
40 if (n
!= strlen (t
->expect
) || strcmp (buf
, t
->expect
) != 0)
42 printf ("%s\tExpected \"%s\" (%Zu)\n\tGot \"%s\" (%d, %Zu)\n",
43 t
->fmt
, t
->expect
, strlen (t
->expect
), buf
, n
, strlen (buf
));
51 #include "../test-skeleton.c"