1 | /* Test for the long double variants of obstrack*printf functions. |
2 | Copyright (C) 2019-2024 Free Software Foundation, Inc. |
3 | This file is part of the GNU C Library. |
4 | |
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. |
9 | |
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. |
14 | |
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/>. */ |
18 | |
19 | #include <malloc.h> |
20 | #include <obstack.h> |
21 | #include <stdio.h> |
22 | #include <string.h> |
23 | #include <stdarg.h> |
24 | |
25 | #include <support/check.h> |
26 | |
27 | #define obstack_chunk_alloc malloc |
28 | #define obstack_chunk_free free |
29 | |
30 | static void |
31 | do_test_call (void *last, ...) |
32 | { |
33 | const char *expected = "-1.000000000000000000000000000000" ; |
34 | char *actual = NULL; |
35 | long double ld = -1; |
36 | struct obstack ob; |
37 | va_list ap; |
38 | |
39 | obstack_init (&ob); |
40 | OBSTACK_FUNCTION OBSTACK_FUNCTION_PARAMS; |
41 | actual = (char *) obstack_finish (&ob); |
42 | TEST_VERIFY (strncmp (expected, actual, 33) == 0); |
43 | obstack_free (&ob, NULL); |
44 | actual = NULL; |
45 | |
46 | obstack_init (&ob); |
47 | va_start (ap, last); |
48 | VOBSTACK_FUNCTION VOBSTACK_FUNCTION_PARAMS; |
49 | va_end (ap); |
50 | actual = (char *) obstack_finish (&ob); |
51 | TEST_VERIFY (strncmp (expected, actual, 33) == 0); |
52 | obstack_free (&ob, NULL); |
53 | actual = NULL; |
54 | } |
55 | |
56 | static int |
57 | do_test (void) |
58 | { |
59 | long double ld = -1; |
60 | do_test_call (NULL, ld); |
61 | return 0; |
62 | } |
63 | |
64 | #include <support/test-driver.c> |
65 | |