From 9c6774f18a5a0be05ac5151611cfe719c63d9b0f Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Fri, 19 Mar 2004 01:53:11 +0000 Subject: [PATCH] Relay msvcrt_memcpy to memmove, CString::Insert seems to rely on that behaviour. Add a test case. --- dlls/msvcrt/msvcrt.spec | 2 +- dlls/msvcrt/tests/.cvsignore | 1 + dlls/msvcrt/tests/Makefile.in | 3 ++- dlls/msvcrt/tests/string.c | 51 +++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 dlls/msvcrt/tests/string.c diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 5f829527582..8a66c2bc88d 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -666,7 +666,7 @@ @ cdecl mbtowc(wstr str long) MSVCRT_mbtowc @ cdecl memchr(ptr long long) @ cdecl memcmp(ptr ptr long) -@ cdecl memcpy(ptr ptr long) +@ cdecl memcpy(ptr ptr long) memmove @ cdecl memmove(ptr ptr long) @ cdecl memset(ptr long long) @ cdecl mktime(ptr) MSVCRT_mktime diff --git a/dlls/msvcrt/tests/.cvsignore b/dlls/msvcrt/tests/.cvsignore index 0ed0da60a2c..b660324acf4 100644 --- a/dlls/msvcrt/tests/.cvsignore +++ b/dlls/msvcrt/tests/.cvsignore @@ -3,4 +3,5 @@ cpp.ok file.ok heap.ok scanf.ok +string.ok testlist.c diff --git a/dlls/msvcrt/tests/Makefile.in b/dlls/msvcrt/tests/Makefile.in index 1d999738d5f..9e604b5f201 100644 --- a/dlls/msvcrt/tests/Makefile.in +++ b/dlls/msvcrt/tests/Makefile.in @@ -10,7 +10,8 @@ CTESTS = \ cpp.c \ file.c \ heap.c \ - scanf.c + scanf.c \ + string.c @MAKE_TEST_RULES@ diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c new file mode 100644 index 00000000000..5310fdebd6d --- /dev/null +++ b/dlls/msvcrt/tests/string.c @@ -0,0 +1,51 @@ +/* + * Unit test suite for string functions. + * + * Copyright 2004 Uwe Bonnes + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "wine/test.h" +#include "winbase.h" +#include +#include + +static void* (*pmemcpy)(void *, const void *, size_t n); +static int* (*pmemcmp)(void *, const void *, size_t n); + +#define SETNOFAIL(x,y) x = (void*)GetProcAddress(hMsvcrt,y) +#define SET(x,y) SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y) + + +START_TEST(string) +{ + void *mem; + char xilstring[]="c:/xilinx"; + int nLen=strlen(xilstring); + HMODULE hMsvcrt = LoadLibraryA("msvcrt.dll"); + ok(hMsvcrt != 0, "LoadLibraryA failed\n"); + SET(pmemcpy,"memcpy"); + SET(pmemcmp,"memcmp"); + + /* MSVCRT memcpy behaves like memmove for overlapping moves, + MFC42 CString::Insert seems to rely on that behaviour */ + mem = malloc(100); + ok(mem != NULL, "memory not allocated for size 0\n"); + strcpy((char*)mem,xilstring); + pmemcpy((char*)mem+5, mem,nLen+1); + ok(pmemcmp((char*)mem+5,xilstring, nLen) == 0, + "Got result %s\n",(char*)mem+5); +}