usleep tests: Avoid failure due to known Cygwin 3.5.3 bug.
[gnulib.git] / tests / test-wcstok.c
blobbfa1092558e21d327eca51381e7f24bc666d5560
1 /* Test of conversion of wide string to string.
2 Copyright (C) 2019-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>, 2019. */
19 #include <config.h>
21 #include <wchar.h>
23 #include "signature.h"
24 SIGNATURE_CHECK (wcstok, wchar_t *,
25 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
27 #include <string.h>
29 #include "macros.h"
31 int
32 main ()
34 wchar_t string[] = L"hello world!";
35 wchar_t delim[] = L" ";
36 wchar_t *ptr;
37 wchar_t *ret;
39 ret = wcstok (string, delim, &ptr);
40 ASSERT (ret == string);
41 ASSERT (memcmp (string, L"hello\0 world!", 14 * sizeof (wchar_t)) == 0);
42 ASSERT (ptr == string + 6);
44 ret = wcstok (NULL, delim, &ptr);
45 ASSERT (ret == string + 7);
46 ASSERT (memcmp (string, L"hello\0 world!", 14 * sizeof (wchar_t)) == 0);
47 ASSERT (ptr == NULL || *ptr == L'\0');
49 ret = wcstok (NULL, delim, &ptr);
50 ASSERT (ret == NULL);
52 return test_exit_status;