* tests/unistr/test-pcpy.h: New file, based on tests/unistr/test-cpy.h.
* tests/unistr/test-u8-pcpy.c: New file, based on
tests/unistr/test-u8-cpy.c.
* tests/unistr/test-u16-pcpy.c: New file, based on
tests/unistr/test-u16-cpy.c.
* tests/unistr/test-u32-pcpy.c: New file, based on
tests/unistr/test-u32-cpy.c.
* modules/unistr/u8-pcpy-tests: New file, based on
modules/unistr/u8-cpy-tests.
* modules/unistr/u16-pcpy-tests: New file, based on
modules/unistr/u16-cpy-tests.
* modules/unistr/u32-pcpy-tests: New file, based on
modules/unistr/u32-cpy-tests.
2023-07-21 Bruno Haible <bruno@clisp.org>
+ unistr/u8-pcpy, unistr/u16-pcpy, unistr/u32-pcpy: Add tests.
+ * tests/unistr/test-pcpy.h: New file, based on tests/unistr/test-cpy.h.
+ * tests/unistr/test-u8-pcpy.c: New file, based on
+ tests/unistr/test-u8-cpy.c.
+ * tests/unistr/test-u16-pcpy.c: New file, based on
+ tests/unistr/test-u16-cpy.c.
+ * tests/unistr/test-u32-pcpy.c: New file, based on
+ tests/unistr/test-u32-cpy.c.
+ * modules/unistr/u8-pcpy-tests: New file, based on
+ modules/unistr/u8-cpy-tests.
+ * modules/unistr/u16-pcpy-tests: New file, based on
+ modules/unistr/u16-cpy-tests.
+ * modules/unistr/u32-pcpy-tests: New file, based on
+ modules/unistr/u32-cpy-tests.
+
unistr/u8-pcpy, unistr/u16-pcpy, unistr/u32-pcpy: New modules.
* lib/unistr.in.h (u8_pcpy, u16_pcpy, u32_pcpy): New declarations.
* lib/unistr/u-pcpy.h: New file, based on lib/wmempcpy.c.
--- /dev/null
+Files:
+tests/unistr/test-u16-pcpy.c
+tests/unistr/test-pcpy.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-u16-pcpy
+check_PROGRAMS += test-u16-pcpy
+test_u16_pcpy_SOURCES = unistr/test-u16-pcpy.c
+test_u16_pcpy_LDADD = $(LDADD) $(LIBUNISTRING)
--- /dev/null
+Files:
+tests/unistr/test-u32-pcpy.c
+tests/unistr/test-pcpy.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-u32-pcpy
+check_PROGRAMS += test-u32-pcpy
+test_u32_pcpy_SOURCES = unistr/test-u32-pcpy.c
+test_u32_pcpy_LDADD = $(LDADD) $(LIBUNISTRING)
--- /dev/null
+Files:
+tests/unistr/test-u8-pcpy.c
+tests/unistr/test-pcpy.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-u8-pcpy
+check_PROGRAMS += test-u8-pcpy
+test_u8_pcpy_SOURCES = unistr/test-u8-pcpy.c
+test_u8_pcpy_LDADD = $(LDADD) $(LIBUNISTRING)
--- /dev/null
+/* Test of uN_pcpy() functions.
+ Copyright (C) 2010-2023 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/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
+
+int
+main ()
+{
+ /* Test small copying operations. */
+ {
+ static const UNIT src[] = { 'c', 'l', 'i', 'm', 'a', 't', 'e' };
+ size_t n;
+
+ for (n = 0; n <= SIZEOF (src); n++)
+ {
+ UNIT dest[1 + SIZEOF (src) + 1] =
+ { MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC };
+ UNIT *ret;
+ size_t i;
+
+ ret = U_PCPY (dest + 1, src, n);
+ ASSERT (ret == dest + 1 + n);
+ ASSERT (dest[0] == MAGIC);
+ for (i = 0; i < n; i++)
+ ASSERT (dest[1 + i] == src[i]);
+ ASSERT (dest[1 + n] == MAGIC);
+ }
+ }
+
+ return 0;
+}
--- /dev/null
+/* Test of u16_pcpy() function.
+ Copyright (C) 2010-2023 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/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
+
+#include <config.h>
+
+#include "unistr.h"
+
+#include "macros.h"
+
+#define UNIT uint16_t
+#define U_PCPY u16_pcpy
+#define MAGIC 0xBADE
+#include "test-pcpy.h"
--- /dev/null
+/* Test of u32_pcpy() function.
+ Copyright (C) 2010-2023 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/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
+
+#include <config.h>
+
+#include "unistr.h"
+
+#include "macros.h"
+
+#define UNIT uint32_t
+#define U_PCPY u32_pcpy
+#define MAGIC 0xBADFACE
+#include "test-pcpy.h"
--- /dev/null
+/* Test of u8_pcpy() function.
+ Copyright (C) 2010-2023 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/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
+
+#include <config.h>
+
+#include "unistr.h"
+
+#include "macros.h"
+
+#define UNIT uint8_t
+#define U_PCPY u8_pcpy
+#define MAGIC 0xBA
+#include "test-pcpy.h"