openat: don’t close (-1)
[gnulib.git] / tests / test-wcsncat.c
blob8ba20a126faa1a744b3963ad8316e9a819a412b4
1 /* Test of wcsncat() function.
2 Copyright (C) 2010-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 #include <config.h>
21 /* Specification. */
22 #include <wchar.h>
24 #include <stddef.h>
26 #include "macros.h"
28 /* Test the library, not the compiler+library. */
29 static wchar_t *
30 lib_wcsncat (wchar_t *ws1, wchar_t const *ws2, size_t n)
32 return wcsncat (ws1, ws2, n);
34 static wchar_t *(*volatile volatile_wcsncat) (wchar_t *, wchar_t const *,
35 size_t)
36 = lib_wcsncat;
37 #undef wcsncat
38 #define wcsncat volatile_wcsncat
40 int
41 main ()
43 /* Test zero-length operations on NULL pointers, allowed by
44 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>. */
46 #if 0 /* I think this is invalid, per ISO C 23 § 7.31.4.3.2. */
47 ASSERT (wcsncat (NULL, L"x", 0) == NULL);
48 #endif
51 wchar_t y[2] = { L'x', 0 };
52 ASSERT (wcsncat (y, NULL, 0) == y);
55 return test_exit_status;