tests/wchar: Add wmemmove() - scc - simple c99 compiler
 (HTM) git clone git://git.simple-cc.org/scc
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit d7543e2d9e5bc064ac6f1b2469511aae17f0ad52
 (DIR) parent 32c148f21e31e4db0d6f05298c8f5b2d2ad7d9c1
 (HTM) Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
       Date:   Tue, 25 Mar 2025 19:35:22 +0100
       
       tests/wchar: Add wmemmove()
       
       Diffstat:
         M src/libc/objs/common-objs.mk        |       1 +
         A src/libc/wchar/wmemmove.c           |      10 ++++++++++
         M tests/libc/execute/.gitignore       |       1 +
         A tests/libc/execute/0051-wmemmove.c  |      30 ++++++++++++++++++++++++++++++
         M tests/libc/execute/libc-tests.lst   |       1 +
       
       5 files changed, 43 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/src/libc/objs/common-objs.mk b/src/libc/objs/common-objs.mk
       @@ -135,6 +135,7 @@ COMMON_OBJS =\
                wchar/wcwidth.$O\
                wchar/wmemchr.$O\
                wchar/wmemcpy.$O\
       +        wchar/wmemmove.$O\
                wchar/wmemcmp.$O\
                wchar/putwc.$O\
                wchar/_validutf8.$O\
 (DIR) diff --git a/src/libc/wchar/wmemmove.c b/src/libc/wchar/wmemmove.c
       @@ -0,0 +1,10 @@
       +#include <string.h>
       +#include <wchar.h>
       +
       +#undef wmemmove
       +
       +wchar_t *
       +wmemmove(wchar_t *d, const wchar_t *s, size_t n)
       +{
       +        return memmove(d, s,  n * sizeof(wchar_t));
       +}
 (DIR) diff --git a/tests/libc/execute/.gitignore b/tests/libc/execute/.gitignore
       @@ -47,5 +47,6 @@
        0048-wcscpy
        0049-wmemchr
        0050-wmemcpy
       +0051-wmemmove
        0053-wmemcmp
        test.log
 (DIR) diff --git a/tests/libc/execute/0051-wmemmove.c b/tests/libc/execute/0051-wmemmove.c
       @@ -0,0 +1,30 @@
       +#include <assert.h>
       +#include <stdio.h>
       +#include <wchar.h>
       +
       +/*
       +output:
       +testing
       +done
       +end:
       +*/
       +
       +int
       +main()
       +{
       +        wchar_t buf[30];
       +        wchar_t def[] = {'d', 'e', 'f', '\0'};
       +        wchar_t abc[] = {'a', 'b', 'c', '\0'};
       +        wchar_t abcdef[]  = {'a', 'b', 'c', 'd', 'e', 'f', '\0'};
       +
       +        puts("testing");
       +
       +        wmemcpy(buf, abcdef, 6);
       +        assert(!wmemcmp(wmemmove(buf, buf+3, 3), def, 3));
       +        wmemcpy(buf, abcdef, 6);
       +        assert(!wmemcmp(wmemmove(buf, buf+3, 0), abc, 3));
       +
       +        puts("done");
       +
       +        return 0;
       +}
 (DIR) diff --git a/tests/libc/execute/libc-tests.lst b/tests/libc/execute/libc-tests.lst
       @@ -46,4 +46,5 @@
        0048-wcscpy
        0049-wmemchr
        0050-wmemcpy
       +0051-wmemmove
        0053-wmemcmp