1
0
mirror of https://git.savannah.gnu.org/git/gnulib.git synced 2026-10-24 00:48:56 +03:00
Files
gnulib/tests/test-wmemset.c
Bruno Haible 8db2020368 tests: Make last patch side-effect free.
* tests/test-bsearch.c: Use another volatile function pointer variable.
* tests/test-memccpy.c: Likewise.
* tests/test-memchr.c: Likewise.
* tests/test-memcmp.c: Likewise.
* tests/test-memcpy.c: Likewise.
* tests/test-memmove.c: Likewise.
* tests/test-memset.c: Likewise.
* tests/test-memset_explicit.c: Likewise.
* tests/test-qsort.c: Likewise.
* tests/test-strncat.c: Likewise.
* tests/test-strncmp.c: Likewise.
* tests/test-strncpy.c: Likewise.
* tests/test-strndup.c: Likewise.
* tests/test-wcsncat.c: Likewise.
* tests/test-wcsncmp.c: Likewise.
* tests/test-wcsncpy.c: Likewise.
* tests/test-wmemchr.c: Likewise.
* tests/test-wmemcmp.c: Likewise.
* tests/test-wmemcpy.c: Likewise.
* tests/test-wmemmove.c: Likewise.
* tests/test-wmemset.c: Likewise.
2026-08-11 22:35:08 +02:00

59 lines
1.7 KiB
C

/* Test of wmemset() function.
Copyright (C) 2024-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <wchar.h>
#include <stddef.h>
#include "macros.h"
/* Test the prototype in <wchar.h> + compiler. */
static wchar_t *
null_wmemset (wchar_t *ws, wchar_t wc, size_t n)
{
wchar_t *p = wmemset (ws, wc, n);
ASSERT (ws == NULL);
return p;
}
static wchar_t *(*volatile volatile_null_wmemset) (wchar_t *, wchar_t, size_t)
= null_wmemset;
/* Test the library, not the compiler+library. */
static wchar_t *
lib_wmemset (wchar_t *ws, wchar_t wc, size_t n)
{
return wmemset (ws, wc, n);
}
static wchar_t *(*volatile volatile_lib_wmemset) (wchar_t *, wchar_t, size_t)
= lib_wmemset;
#undef wmemset
#define wmemset volatile_lib_wmemset
int
main (void)
{
/* Test zero-length operations on NULL pointers, allowed by
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>. */
ASSERT (wmemset (NULL, L'?', 0) == NULL);
ASSERT (volatile_null_wmemset (NULL, L'?', 0) == NULL);
return test_exit_status;
}