openat: don’t close (-1)
[gnulib.git] / tests / test-obstack-zprintf.c
blob143424604eecb601f3d3edb1cbadd20fc847e546
1 /* Test of obstack_zprintf() and obstack_vzprintf() functions.
2 Copyright (C) 2008-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 #include <config.h>
19 /* Specification. */
20 #include <stdio.h>
22 #include "signature.h"
23 SIGNATURE_CHECK (obstack_zprintf, ptrdiff_t,
24 (struct obstack *, char const *, ...));
25 SIGNATURE_CHECK (obstack_vzprintf, ptrdiff_t,
26 (struct obstack *, char const *, va_list));
28 #include "obstack.h"
29 #include "xalloc.h"
31 #include <stdarg.h>
32 #include <stdlib.h>
33 #include <string.h>
35 #include "macros.h"
37 #define RETTYPE ptrdiff_t
38 #include "test-obstack-printf.h"
40 static ptrdiff_t
41 my_obstack_zprintf (struct obstack *obs, const char *format, ...)
43 va_list args;
44 ptrdiff_t ret;
46 va_start (args, format);
47 ret = obstack_vzprintf (obs, format, args);
48 va_end (args);
49 return ret;
52 int
53 main (int argc, char *argv[])
55 test_function (my_obstack_zprintf);
56 test_function (obstack_zprintf);
57 return test_exit_status;