sethostname tests: Avoid test failure on Cygwin.
[gnulib.git] / tests / test-printf-gnu.h
blob1dd9d026f770a9cdf84c20de0ae03b1abffb9ea6
1 /* Test of POSIX and GNU compatible vsprintf() and sprintf() functions.
2 Copyright (C) 2007-2024 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2023. */
19 static void
20 test_function (int (*my_printf) (const char *, ...))
22 /* Here we don't test output that may be platform dependent.
23 The bulk of the tests is done as part of the 'vasnprintf-posix' module. */
25 /* Test the support of the 'B' conversion specifier for binary output of
26 integers. */
28 /* Zero. */
29 my_printf ("%B %d\n", 0, 33, 44, 55);
31 /* A positive number. */
32 my_printf ("%B %d\n", 12345, 33, 44, 55);
34 /* A large positive number. */
35 my_printf ("%B %d\n", 0xFFFFFFFEU, 33, 44, 55);
37 /* Width. */
38 my_printf ("%20B %d\n", 12345, 33, 44, 55);
40 /* Width given as argument. */
41 my_printf ("%*B %d\n", 20, 12345, 33, 44, 55);
43 /* Negative width given as argument (cf. FLAG_LEFT below). */
44 my_printf ("%*B %d\n", -20, 12345, 33, 44, 55);
46 /* Precision. */
47 my_printf ("%.20B %d\n", 12345, 33, 44, 55);
49 /* Zero precision and a positive number. */
50 my_printf ("%.0B %d\n", 12345, 33, 44, 55);
52 /* Zero precision and a zero number. */
53 my_printf ("%.0B %d\n", 0, 33, 44, 55);
55 /* Width and precision. */
56 my_printf ("%25.20B %d\n", 12345, 33, 44, 55);
58 /* FLAG_LEFT. */
59 my_printf ("%-20B %d\n", 12345, 33, 44, 55);
61 /* FLAG_ALT with zero. */
62 my_printf ("%#B %d\n", 0, 33, 44, 55);
64 /* FLAG_ALT with a positive number. */
65 my_printf ("%#B %d\n", 12345, 33, 44, 55);
67 /* FLAG_ALT with a positive number and width. */
68 my_printf ("%#20B %d\n", 12345, 33, 44, 55);
70 /* FLAG_ALT with a positive number and padding. */
71 my_printf ("%0#20B %d\n", 12345, 33, 44, 55);
73 /* FLAG_ALT with a positive number and precision. */
74 my_printf ("%0#.20B %d\n", 12345, 33, 44, 55);
76 /* FLAG_ALT with a positive number and width and precision. */
77 my_printf ("%#25.20B %d\n", 12345, 33, 44, 55);
79 /* FLAG_ALT with a zero precision and a zero number. */
80 my_printf ("%#.0B %d\n", 0, 33, 44, 55);