2 * Unit test suite for string functions.
4 * Copyright 2004 Uwe Bonnes
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "wine/test.h"
27 static void* (*pmemcpy)(void *, const void *, size_t n);
28 static int* (*pmemcmp)(void *, const void *, size_t n);
30 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(hMsvcrt,y)
31 #define SET(x,y) SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y)
33 static void test_swab( void ) {
34 char original[] = "BADCFEHGJILKNMPORQTSVUXWZY@#";
35 char expected1[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ@#";
36 char expected2[] = "ABCDEFGHIJKLMNOPQRSTUVWX$";
37 char expected3[] = "$";
44 /* Test 1 - normal even case */
45 memset(to,'$', sizeof(to));
46 memset(from,'@', sizeof(from));
48 memcpy(from, original, testsize);
49 _swab( from, to, testsize );
50 ok(memcmp(to,expected1,testsize) == 0, "Testing even size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
52 /* Test 2 - uneven case */
53 memset(to,'$', sizeof(to));
54 memset(from,'@', sizeof(from));
56 memcpy(from, original, testsize);
57 _swab( from, to, testsize );
58 ok(memcmp(to,expected2,testsize) == 0, "Testing odd size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
60 /* Test 3 - from = to */
61 memset(to,'$', sizeof(to));
62 memset(from,'@', sizeof(from));
64 memcpy(to, original, testsize);
65 _swab( to, to, testsize );
66 ok(memcmp(to,expected1,testsize) == 0, "Testing overlapped size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
68 /* Test 4 - 1 bytes */
69 memset(to,'$', sizeof(to));
70 memset(from,'@', sizeof(from));
72 memcpy(from, original, testsize);
73 _swab( from, to, testsize );
74 ok(memcmp(to,expected3,testsize) == 0, "Testing small size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
79 unsigned int s = '\354';
82 todo_wine ok(_ismbblead(s) == 4, "got result %d\n", _ismbblead(s));
89 static const char xilstring[]="c:/xilinx";
90 int nLen=strlen(xilstring);
91 HMODULE hMsvcrt = LoadLibraryA("msvcrt.dll");
92 ok(hMsvcrt != 0, "LoadLibraryA failed\n");
93 SET(pmemcpy,"memcpy");
94 SET(pmemcmp,"memcmp");
96 /* MSVCRT memcpy behaves like memmove for overlapping moves,
97 MFC42 CString::Insert seems to rely on that behaviour */
99 ok(mem != NULL, "memory not allocated for size 0\n");
100 strcpy((char*)mem,xilstring);
101 pmemcpy((char*)mem+5, mem,nLen+1);
102 ok(pmemcmp((char*)mem+5,xilstring, nLen) == 0,
103 "Got result %s\n",(char*)mem+5);
105 /* Test _swab function */