openat: don’t close (-1)
[gnulib.git] / tests / test-vaszprintf-gnu.h
blob4b6cb493c08fd38e62705f66dd9001b85aca3361
1 /* Test of POSIX and GNU compatible [v]aszprintf(), c_[v]aszprintf() 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>, 2024. */
19 static void
20 test_function (ptrdiff_t (*my_aszprintf) (char **, const char *, ...))
22 /* Test the support of the 'B' conversion specifier for binary output of
23 integers. */
25 { /* This test would fail on all platforms other than glibc ≥ 2.35. */
26 char *result;
27 ptrdiff_t retval =
28 my_aszprintf (&result, "%#B %d", 12345, 33, 44, 55);
29 ASSERT (result != NULL);
30 ASSERT (strcmp (result, "0B11000000111001 33") == 0);
31 ASSERT (retval == strlen (result));
32 free (result);