1 /* Test for the long double variants of *w*printf functions.
2 Copyright (C) 2019-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
24 #include <support/capture_subprocess.h>
25 #include <support/check.h>
28 do_test_call_varg (FILE *stream
, const wchar_t *format
, ...)
33 wprintf (L
"%15Ls", L
"vfwprintf: ");
34 va_start (args
, format
);
35 vfwprintf (stream
, format
, args
);
39 wprintf (L
"%15Ls", L
"vswprintf: ");
40 va_start (args
, format
);
41 vswprintf (string
, 127, format
, args
);
43 wprintf (L
"%Ls", string
);
46 wprintf (L
"%15Ls", L
"vwprintf: ");
47 va_start (args
, format
);
48 vwprintf (format
, args
);
54 do_test_call_rarg (FILE *stream
, const wchar_t *format
, long double ld
,
59 wprintf (L
"%15Ls", L
"fwprintf: ");
60 fwprintf (stream
, format
, ld
, d
);
63 wprintf (L
"%15Ls", L
"swprintf: ");
64 swprintf (string
, 127, format
, ld
, d
);
65 wprintf (L
"%Ls", string
);
68 wprintf (L
"%15Ls", L
"wprintf: ");
69 wprintf (format
, ld
, d
);
79 /* Print in decimal notation. */
80 do_test_call_rarg (stdout
, L
"%.10Lf, %.10f", ld
, d
);
81 do_test_call_varg (stdout
, L
"%.10Lf, %.10f", ld
, d
);
83 /* Print in hexadecimal notation. */
84 do_test_call_rarg (stdout
, L
"%.10La, %.10a", ld
, d
);
85 do_test_call_varg (stdout
, L
"%.10La, %.10a", ld
, d
);
87 /* Test positional parameters. */
88 do_test_call_varg (stdout
, L
"%3$Lf, %2$Lf, %1$f",
89 (double) 1, (long double) 2, (long double) 3);
95 struct support_capture_subprocess result
;
96 result
= support_capture_subprocess ((void *) &do_test_call
, NULL
);
98 /* Compare against the expected output. */
99 const char *expected
=
100 " fwprintf: -1.0000000000, -1.0000000000\n"
101 " swprintf: -1.0000000000, -1.0000000000\n"
102 " wprintf: -1.0000000000, -1.0000000000\n"
103 " vfwprintf: -1.0000000000, -1.0000000000\n"
104 " vswprintf: -1.0000000000, -1.0000000000\n"
105 " vwprintf: -1.0000000000, -1.0000000000\n"
106 " fwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
107 " swprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
108 " wprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
109 " vfwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
110 " vswprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
111 " vwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
112 " vfwprintf: 3.000000, 2.000000, 1.000000\n"
113 " vswprintf: 3.000000, 2.000000, 1.000000\n"
114 " vwprintf: 3.000000, 2.000000, 1.000000\n";
115 TEST_COMPARE_STRING (expected
, result
.out
.buffer
);
120 #include <support/test-driver.c>