1 /* Unit test suite for SHLWAPI string functions
3 * Copyright 2003 Jon Griffiths
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/test.h"
26 #define NO_SHLWAPI_REG
27 #define NO_SHLWAPI_PATH
28 #define NO_SHLWAPI_GDI
29 #define NO_SHLWAPI_STREAM
33 static HMODULE hShlwapi;
34 static LPSTR (WINAPI *pStrCpyNXA)(LPSTR,LPCSTR,int);
35 static LPWSTR (WINAPI *pStrCpyNXW)(LPWSTR,LPCWSTR,int);
36 static HRESULT (WINAPI *pStrRetToBSTR)(STRRET*,void*,BSTR*);
37 static DWORD (WINAPI *pSHAnsiToAnsi)(LPCSTR,LPSTR,int);
38 static DWORD (WINAPI *pSHUnicodeToUnicode)(LPCWSTR,LPWSTR,int);
39 static BOOL (WINAPI *pStrIsIntlEqualA)(BOOL,LPCSTR,LPCSTR,int);
40 static BOOL (WINAPI *pIntlStrEqWorkerA)(BOOL,LPCSTR,LPCSTR,int);
41 static BOOL (WINAPI *pStrIsIntlEqualW)(BOOL,LPCWSTR,LPCWSTR,int);
42 static BOOL (WINAPI *pIntlStrEqWorkerW)(BOOL,LPCWSTR,LPCWSTR,int);
44 static int strcmpW(const WCHAR *str1, const WCHAR *str2)
46 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
50 /* StrToInt/StrToIntEx results */
51 typedef struct tagStrToIntResult
59 static const StrToIntResult StrToInt_results[] = {
60 { "1099", 1099, 1099, 1099 },
61 { "+88987", 0, 88987, 88987 },
62 { "012", 12, 12, 12 },
63 { "-55", -55, -55, -55 },
65 { "0x44ff", 0, 0, 0x44ff },
66 { "+0x44f4", 0, 0, 0x44f4 },
67 { "-0x44fd", 0, 0, 0x44fd },
68 { "+ 88987", 0, 0, 0 },
71 { "+ 0x44f4", 0, 0, 0 },
72 { "--0x44fd", 0, 0, 0 },
73 { " 1999", 0, 1999, 1999 },
74 { " +88987", 0, 88987, 88987 },
75 { " 012", 0, 12, 12 },
76 { " -55", 0, -55, -55 },
77 { " 0x44ff", 0, 0, 0x44ff },
78 { " +0x44f4", 0, 0, 0x44f4 },
79 { " -0x44fd", 0, 0, 0x44fd },
83 /* pStrFormatByteSize64/StrFormatKBSize results */
84 typedef struct tagStrFormatSizeResult
87 const char* byte_size_64;
89 } StrFormatSizeResult;
92 static const StrFormatSizeResult StrFormatSize_results[] = {
93 { -1023, "-1023 bytes", "0 KB"},
94 { -24, "-24 bytes", "0 KB"},
95 { 309, "309 bytes", "1 KB"},
96 { 10191, "9.95 KB", "10 KB"},
97 { 100353, "98.0 KB", "99 KB"},
98 { 1022286, "998 KB", "999 KB"},
99 { 1046862, "0.99 MB", "1,023 KB"},
100 { 1048574619, "999 MB", "1,023,999 KB"},
101 { 1073741775, "0.99 GB", "1,048,576 KB"},
102 { ((LONGLONG)0x000000f9 << 32) | 0xfffff94e, "999 GB", "1,048,575,999 KB"},
103 { ((LONGLONG)0x000000ff << 32) | 0xfffffa9b, "0.99 TB", "1,073,741,823 KB"},
104 { ((LONGLONG)0x0003e7ff << 32) | 0xfffffa9b, "999 TB", "1,073,741,823,999 KB"},
105 { ((LONGLONG)0x0003ffff << 32) | 0xfffffbe8, "0.99 PB", "1,099,511,627,775 KB"},
106 { ((LONGLONG)0x0f9fffff << 32) | 0xfffffd35, "999 PB", "1,099,511,627,776,000 KB"},
107 { ((LONGLONG)0x0fffffff << 32) | 0xfffffa9b, "0.99 EB", "1,125,899,906,842,623 KB"},
111 /* StrFormatByteSize64/StrFormatKBSize results */
112 typedef struct tagStrFromTimeIntervalResult
116 const char* time_interval;
117 } StrFromTimeIntervalResult;
120 static const StrFromTimeIntervalResult StrFromTimeInterval_results[] = {
129 { 1000000, 1, " 10 min" },
130 { 1000000, 2, " 16 min" },
131 { 1000000, 3, " 16 min 40 sec" },
132 { 1000000, 4, " 16 min 40 sec" },
133 { 1000000, 5, " 16 min 40 sec" },
134 { 1000000, 6, " 16 min 40 sec" },
135 { 1000000, 7, " 16 min 40 sec" },
137 { 1999999, 1, " 30 min" },
138 { 1999999, 2, " 33 min" },
139 { 1999999, 3, " 33 min 20 sec" },
140 { 1999999, 4, " 33 min 20 sec" },
141 { 1999999, 5, " 33 min 20 sec" },
142 { 1999999, 6, " 33 min 20 sec" },
143 { 1999999, 7, " 33 min 20 sec" },
145 { 3999997, 1, " 1 hr" },
146 { 3999997, 2, " 1 hr 6 min" },
147 { 3999997, 3, " 1 hr 6 min 40 sec" },
148 { 3999997, 4, " 1 hr 6 min 40 sec" },
149 { 3999997, 5, " 1 hr 6 min 40 sec" },
150 { 3999997, 6, " 1 hr 6 min 40 sec" },
151 { 3999997, 7, " 1 hr 6 min 40 sec" },
153 { 149999851, 7, " 41 hr 40 min 0 sec" },
154 { 150999850, 1, " 40 hr" },
155 { 150999850, 2, " 41 hr" },
156 { 150999850, 3, " 41 hr 50 min" },
157 { 150999850, 4, " 41 hr 56 min" },
158 { 150999850, 5, " 41 hr 56 min 40 sec" },
159 { 150999850, 6, " 41 hr 56 min 40 sec" },
160 { 150999850, 7, " 41 hr 56 min 40 sec" },
162 { 493999507, 1, " 100 hr" },
163 { 493999507, 2, " 130 hr" },
164 { 493999507, 3, " 137 hr" },
165 { 493999507, 4, " 137 hr 10 min" },
166 { 493999507, 5, " 137 hr 13 min" },
167 { 493999507, 6, " 137 hr 13 min 20 sec" },
168 { 493999507, 7, " 137 hr 13 min 20 sec" },
173 static void test_StrChrA(void)
178 /* this test crashes on win2k SP4 */
179 /*ok(!StrChrA(NULL,'\0'), "found a character in a NULL string!\n");*/
181 for (count = 32; count < 128; count++)
182 string[count] = (char)count;
185 for (count = 32; count < 128; count++)
187 LPSTR result = StrChrA(string+32, count);
188 ok(result - string == count,
189 "found char '%c' in wrong place: got %d, expected %d\n",
190 count, result - string, count);
193 for (count = 32; count < 128; count++)
195 LPSTR result = StrChrA(string+count+1, count);
196 ok(!result, "found char '%c' not in the string\n", count);
200 static void test_StrChrW(void)
205 /* this test crashes on win2k SP4 */
206 /*ok(!StrChrW(NULL,'\0'), "found a character in a NULL string!\n");*/
208 for (count = 32; count < 16384; count++)
209 string[count] = count;
210 string[16384] = '\0';
212 for (count = 32; count < 16384; count++)
214 LPWSTR result = StrChrW(string+32, count);
215 ok((result - string) == count, "found char %d in wrong place\n", count);
218 for (count = 32; count < 16384; count++)
220 LPWSTR result = StrChrW(string+count+1, count);
221 ok(!result, "found char not in the string\n");
225 static void test_StrChrIA(void)
230 /* this test crashes on win2k SP4 */
231 /*ok(!StrChrIA(NULL,'\0'), "found a character in a NULL string!\n");*/
233 for (count = 32; count < 128; count++)
234 string[count] = (char)count;
237 for (count = 'A'; count <= 'X'; count++)
239 LPSTR result = StrChrIA(string+32, count);
241 ok(result - string == count, "found char '%c' in wrong place\n", count);
242 ok(StrChrIA(result, count)!=NULL, "didn't find lowercase '%c'\n", count);
245 for (count = 'a'; count < 'z'; count++)
247 LPSTR result = StrChrIA(string+count+1, count);
248 ok(!result, "found char not in the string\n");
252 static void test_StrChrIW(void)
257 /* this test crashes on win2k SP4 */
258 /*ok(!StrChrIA(NULL,'\0'), "found a character in a NULL string!\n");*/
260 for (count = 32; count < 128; count++)
261 string[count] = count;
264 for (count = 'A'; count <= 'X'; count++)
266 LPWSTR result = StrChrIW(string+32, count);
268 ok(result - string == count, "found char '%c' in wrong place\n", count);
269 ok(StrChrIW(result, count)!=NULL, "didn't find lowercase '%c'\n", count);
272 for (count = 'a'; count < 'z'; count++)
274 LPWSTR result = StrChrIW(string+count+1, count);
275 ok(!result, "found char not in the string\n");
279 static void test_StrRChrA(void)
284 /* this test crashes on win2k SP4 */
285 /*ok(!StrRChrA(NULL, NULL,'\0'), "found a character in a NULL string!\n");*/
287 for (count = 32; count < 128; count++)
288 string[count] = (char)count;
291 for (count = 32; count < 128; count++)
293 LPSTR result = StrRChrA(string+32, NULL, count);
294 ok(result - string == count, "found char %d in wrong place\n", count);
297 for (count = 32; count < 128; count++)
299 LPSTR result = StrRChrA(string+count+1, NULL, count);
300 ok(!result, "found char not in the string\n");
303 for (count = 32; count < 128; count++)
305 LPSTR result = StrRChrA(string+count+1, string + 127, count);
306 ok(!result, "found char not in the string\n");
310 static void test_StrRChrW(void)
315 /* this test crashes on win2k SP4 */
316 /*ok(!StrRChrW(NULL, NULL,'\0'), "found a character in a NULL string!\n");*/
318 for (count = 32; count < 128; count++)
319 string[count] = count;
322 for (count = 32; count < 128; count++)
324 LPWSTR result = StrRChrW(string+32, NULL, count);
325 ok(result - string == count,
326 "found char %d in wrong place: got %d, expected %d\n",
327 count, result - string, count);
330 for (count = 32; count < 128; count++)
332 LPWSTR result = StrRChrW(string+count+1, NULL, count);
333 ok(!result, "found char %d not in the string\n", count);
336 for (count = 32; count < 128; count++)
338 LPWSTR result = StrRChrW(string+count+1, string + 127, count);
339 ok(!result, "found char %d not in the string\n", count);
343 static void test_StrCpyW(void)
347 const StrFormatSizeResult* result = StrFormatSize_results;
352 MultiByteToWideChar(0,0,result->byte_size_64,-1,szSrc,sizeof(szSrc)/sizeof(WCHAR));
354 StrCpyW(szBuff, szSrc);
355 ok(!StrCmpW(szSrc, szBuff), "Copied string %s wrong\n", result->byte_size_64);
361 static void test_StrToIntA(void)
363 const StrToIntResult *result = StrToInt_results;
366 while (result->string)
368 return_val = StrToIntA(result->string);
369 ok(return_val == result->str_to_int, "converted '%s' wrong (%d)\n",
370 result->string, return_val);
375 static void test_StrToIntW(void)
378 const StrToIntResult *result = StrToInt_results;
381 while (result->string)
383 MultiByteToWideChar(0,0,result->string,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR));
384 return_val = StrToIntW(szBuff);
385 ok(return_val == result->str_to_int, "converted '%s' wrong (%d)\n",
386 result->string, return_val);
391 static void test_StrToIntExA(void)
393 const StrToIntResult *result = StrToInt_results;
397 while (result->string)
400 bRet = StrToIntExA(result->string,0,&return_val);
401 ok(!bRet || return_val != -1, "No result returned from '%s'\n",
404 ok(return_val == result->str_to_int_ex, "converted '%s' wrong (%d)\n",
405 result->string, return_val);
409 result = StrToInt_results;
410 while (result->string)
413 bRet = StrToIntExA(result->string,STIF_SUPPORT_HEX,&return_val);
414 ok(!bRet || return_val != -1, "No result returned from '%s'\n",
417 ok(return_val == result->str_to_int_hex, "converted '%s' wrong (%d)\n",
418 result->string, return_val);
423 static void test_StrToIntExW(void)
426 const StrToIntResult *result = StrToInt_results;
430 while (result->string)
433 MultiByteToWideChar(0,0,result->string,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR));
434 bRet = StrToIntExW(szBuff, 0, &return_val);
435 ok(!bRet || return_val != -1, "No result returned from '%s'\n",
438 ok(return_val == result->str_to_int_ex, "converted '%s' wrong (%d)\n",
439 result->string, return_val);
443 result = StrToInt_results;
444 while (result->string)
447 MultiByteToWideChar(0,0,result->string,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR));
448 bRet = StrToIntExW(szBuff, STIF_SUPPORT_HEX, &return_val);
449 ok(!bRet || return_val != -1, "No result returned from '%s'\n",
452 ok(return_val == result->str_to_int_hex, "converted '%s' wrong (%d)\n",
453 result->string, return_val);
458 static void test_StrDupA(void)
461 const StrFormatSizeResult* result = StrFormatSize_results;
465 lpszStr = StrDupA(result->byte_size_64);
467 ok(lpszStr != NULL, "Dup failed\n");
470 ok(!strcmp(result->byte_size_64, lpszStr), "Copied string wrong\n");
471 LocalFree((HLOCAL)lpszStr);
476 /* Later versions of shlwapi return NULL for this, but earlier versions
477 * returned an empty string (as Wine does).
479 lpszStr = StrDupA(NULL);
480 ok(lpszStr == NULL || *lpszStr == '\0', "NULL string returned %p\n", lpszStr);
483 static void test_StrFormatByteSize64A(void)
486 const StrFormatSizeResult* result = StrFormatSize_results;
490 StrFormatByteSize64A(result->value, szBuff, 256);
492 ok(!strcmp(result->byte_size_64, szBuff),
493 "Formatted %x%08x wrong: got %s, expected %s\n",
494 (LONG)(result->value >> 32), (LONG)result->value, szBuff, result->byte_size_64);
500 static void test_StrFormatKBSizeW(void)
504 const StrFormatSizeResult* result = StrFormatSize_results;
508 StrFormatKBSizeW(result->value, szBuffW, 256);
509 WideCharToMultiByte(0,0,szBuffW,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR),0,0);
510 ok(!strcmp(result->kb_size, szBuff),
511 "Formatted %x%08x wrong: got %s, expected %s\n",
512 (LONG)(result->value >> 32), (LONG)result->value, szBuff, result->kb_size);
517 static void test_StrFormatKBSizeA(void)
520 const StrFormatSizeResult* result = StrFormatSize_results;
524 StrFormatKBSizeA(result->value, szBuff, 256);
526 ok(!strcmp(result->kb_size, szBuff),
527 "Formatted %x%08x wrong: got %s, expected %s\n",
528 (LONG)(result->value >> 32), (LONG)result->value, szBuff, result->kb_size);
533 static void test_StrFromTimeIntervalA(void)
536 const StrFromTimeIntervalResult* result = StrFromTimeInterval_results;
540 StrFromTimeIntervalA(szBuff, 256, result->ms, result->digits);
542 ok(!strcmp(result->time_interval, szBuff), "Formatted %d %d wrong\n",
543 result->ms, result->digits);
548 static void test_StrCmpA(void)
550 static const char str1[] = {'a','b','c','d','e','f'};
551 static const char str2[] = {'a','B','c','d','e','f'};
552 ok(0 != StrCmpNA(str1, str2, 6), "StrCmpNA is case-insensitive\n");
553 ok(0 == StrCmpNIA(str1, str2, 6), "StrCmpNIA is case-sensitive\n");
554 ok(!ChrCmpIA('a', 'a'), "ChrCmpIA doesn't work at all!\n");
555 ok(!ChrCmpIA('b', 'B'), "ChrCmpIA is not case-insensitive\n");
556 ok(ChrCmpIA('a', 'z'), "ChrCmpIA believes that a == z!\n");
558 pStrIsIntlEqualA = (void *)GetProcAddress(hShlwapi, "StrIsIntlEqualA");
559 pIntlStrEqWorkerA = (void *)GetProcAddress(hShlwapi, "IntlStrEqWorkerA");
561 if (!pStrIsIntlEqualA)
564 ok(pStrIsIntlEqualA(FALSE, str1, str2, 5), "StrIsIntlEqualA(FALSE,...) isn't case-insensitive\n");
565 ok(!pStrIsIntlEqualA(TRUE, str1, str2, 5), "StrIsIntlEqualA(TRUE,...) isn't case-sensitive\n");
567 if (!pIntlStrEqWorkerA)
570 ok(pIntlStrEqWorkerA(FALSE, str1, str2, 5), "IntlStrEqWorkerA(FALSE,...) isn't case-insensitive\n");
571 ok(!pIntlStrEqWorkerA(TRUE, str1, str2, 5), "pIntlStrEqWorkerA(TRUE,...) isn't case-sensitive\n");
574 static void test_StrCmpW(void)
576 static const WCHAR str1[] = {'a','b','c','d','e','f'};
577 static const WCHAR str2[] = {'a','B','c','d','e','f'};
578 ok(0 != StrCmpNW(str1, str2, 5), "StrCmpNW is case-insensitive\n");
579 ok(0 == StrCmpNIW(str1, str2, 5), "StrCmpNIW is case-sensitive\n");
580 ok(!ChrCmpIW('a', 'a'), "ChrCmpIW doesn't work at all!\n");
581 ok(!ChrCmpIW('b', 'B'), "ChrCmpIW is not case-insensitive\n");
582 ok(ChrCmpIW('a', 'z'), "ChrCmpIW believes that a == z!\n");
584 pStrIsIntlEqualW = (void *)GetProcAddress(hShlwapi, "StrIsIntlEqualW");
585 pIntlStrEqWorkerW = (void *)GetProcAddress(hShlwapi, "IntlStrEqWorkerW");
587 if (!pStrIsIntlEqualW)
590 ok(pStrIsIntlEqualW(FALSE, str1, str2, 5), "StrIsIntlEqualW(FALSE,...) isn't case-insensitive\n");
591 ok(!pStrIsIntlEqualW(TRUE, str1, str2, 5), "StrIsIntlEqualW(TRUE,...) isn't case-sensitive\n");
593 if (!pIntlStrEqWorkerW)
596 ok(pIntlStrEqWorkerW(FALSE, str1, str2, 5), "IntlStrEqWorkerW(FALSE,...) isn't case-insensitive\n");
597 ok(!pIntlStrEqWorkerW(TRUE, str1, str2, 5), "IntlStrEqWorkerW(TRUE,...) isn't case-sensitive\n");
600 static WCHAR *CoDupStrW(const char* src)
602 INT len = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0);
603 WCHAR* szTemp = (WCHAR*)CoTaskMemAlloc(len * sizeof(WCHAR));
604 MultiByteToWideChar(CP_ACP, 0, src, -1, szTemp, len);
608 static void test_StrRetToBSTR(void)
610 static const WCHAR szTestW[] = { 'T','e','s','t','\0' };
616 pStrRetToBSTR = (void *)GetProcAddress(hShlwapi, "StrRetToBSTR");
617 if (!pStrRetToBSTR) return;
619 strret.uType = STRRET_WSTR;
620 U(strret).pOleStr = CoDupStrW("Test");
622 ret = pStrRetToBSTR(&strret, NULL, &bstr);
623 ok(ret == S_OK && bstr && !strcmpW(bstr, szTestW),
624 "STRRET_WSTR: dup failed, ret=0x%08x, bstr %p\n", ret, bstr);
628 strret.uType = STRRET_CSTR;
629 lstrcpyA(U(strret).cStr, "Test");
630 ret = pStrRetToBSTR(&strret, NULL, &bstr);
631 ok(ret == S_OK && bstr && !strcmpW(bstr, szTestW),
632 "STRRET_CSTR: dup failed, ret=0x%08x, bstr %p\n", ret, bstr);
636 strret.uType = STRRET_OFFSET;
637 U(strret).uOffset = 1;
638 strcpy((char*)&iidl, " Test");
639 ret = pStrRetToBSTR(&strret, iidl, &bstr);
640 ok(ret == S_OK && bstr && !strcmpW(bstr, szTestW),
641 "STRRET_OFFSET: dup failed, ret=0x%08x, bstr %p\n", ret, bstr);
645 /* Native crashes if str is NULL */
648 static void test_StrCpyNXA(void)
650 LPCSTR lpSrc = "hello";
654 pStrCpyNXA = (void *)GetProcAddress(hShlwapi, (LPSTR)399);
658 memset(dest, '\n', sizeof(dest));
659 lpszRes = pStrCpyNXA(dest, lpSrc, sizeof(dest)/sizeof(dest[0]));
660 ok(lpszRes == dest + 5 && !memcmp(dest, "hello\0\n\n", sizeof(dest)),
661 "StrCpyNXA: expected %p, \"hello\\0\\n\\n\", got %p, \"%d,%d,%d,%d,%d,%d,%d,%d\"\n",
662 dest + 5, lpszRes, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
665 static void test_StrCpyNXW(void)
667 static const WCHAR lpInit[] = { '\n','\n','\n','\n','\n','\n','\n','\n' };
668 static const WCHAR lpSrc[] = { 'h','e','l','l','o','\0' };
669 static const WCHAR lpRes[] = { 'h','e','l','l','o','\0','\n','\n' };
673 pStrCpyNXW = (void *)GetProcAddress(hShlwapi, (LPSTR)400);
677 memcpy(dest, lpInit, sizeof(lpInit));
678 lpszRes = pStrCpyNXW(dest, lpSrc, sizeof(dest)/sizeof(dest[0]));
679 ok(lpszRes == dest + 5 && !memcmp(dest, lpRes, sizeof(dest)),
680 "StrCpyNXA: expected %p, \"hello\\0\\n\\n\", got %p, \"%d,%d,%d,%d,%d,%d,%d,%d\"\n",
681 dest + 5, lpszRes, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
684 #define check_strrstri(type, str, pos, needle, exp) \
685 ret##type = StrRStrI##type(str, str+pos, needle); \
686 ok(ret##type == (exp), "Type " #type ", expected %p but got %p (string base %p)\n", \
687 (exp), ret##type, str);
689 static void test_StrRStrI()
691 static const CHAR szTest[] = "yAxxxxAy";
692 static const CHAR szTest2[] = "ABABABAB";
693 static const WCHAR wszTest[] = {'y','A','x','x','x','x','A','y',0};
694 static const WCHAR wszTest2[] = {'A','B','A','B','A','B','A','B',0};
696 static const WCHAR wszPattern1[] = {'A',0};
697 static const WCHAR wszPattern2[] = {'a','X',0};
698 static const WCHAR wszPattern3[] = {'A','y',0};
699 static const WCHAR wszPattern4[] = {'a','b',0};
703 check_strrstri(A, szTest, 4, "A", szTest+1);
704 check_strrstri(A, szTest, 4, "aX", szTest+1);
705 check_strrstri(A, szTest, 4, "Ay", NULL);
706 check_strrstri(W, wszTest, 4, wszPattern1, wszTest+1);
707 check_strrstri(W, wszTest, 4, wszPattern2, wszTest+1);
708 check_strrstri(W, wszTest, 4, wszPattern3, NULL);
710 check_strrstri(A, szTest2, 4, "ab", szTest2+2);
711 check_strrstri(A, szTest2, 3, "ab", szTest2+2);
712 check_strrstri(A, szTest2, 2, "ab", szTest2);
713 check_strrstri(A, szTest2, 1, "ab", szTest2);
714 check_strrstri(A, szTest2, 0, "ab", NULL);
715 check_strrstri(W, wszTest2, 4, wszPattern4, wszTest2+2);
716 check_strrstri(W, wszTest2, 3, wszPattern4, wszTest2+2);
717 check_strrstri(W, wszTest2, 2, wszPattern4, wszTest2);
718 check_strrstri(W, wszTest2, 1, wszPattern4, wszTest2);
719 check_strrstri(W, wszTest2, 0, wszPattern4, NULL);
723 static void test_SHAnsiToAnsi(void)
728 pSHAnsiToAnsi = (void *)GetProcAddress(hShlwapi, (LPSTR)345);
732 memset(dest, '\n', sizeof(dest));
733 dwRet = pSHAnsiToAnsi("hello", dest, sizeof(dest)/sizeof(dest[0]));
734 ok(dwRet == 6 && !memcmp(dest, "hello\0\n\n", sizeof(dest)),
735 "SHAnsiToAnsi: expected 6, \"hello\\0\\n\\n\", got %d, \"%d,%d,%d,%d,%d,%d,%d,%d\"\n",
736 dwRet, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
739 static void test_SHUnicodeToUnicode(void)
741 static const WCHAR lpInit[] = { '\n','\n','\n','\n','\n','\n','\n','\n' };
742 static const WCHAR lpSrc[] = { 'h','e','l','l','o','\0' };
743 static const WCHAR lpRes[] = { 'h','e','l','l','o','\0','\n','\n' };
747 pSHUnicodeToUnicode = (void *)GetProcAddress(hShlwapi, (LPSTR)346);
748 if (!pSHUnicodeToUnicode)
751 memcpy(dest, lpInit, sizeof(lpInit));
752 dwRet = pSHUnicodeToUnicode(lpSrc, dest, sizeof(dest)/sizeof(dest[0]));
753 ok(dwRet == 6 && !memcmp(dest, lpRes, sizeof(dest)),
754 "SHUnicodeToUnicode: expected 6, \"hello\\0\\n\\n\", got %d, \"%d,%d,%d,%d,%d,%d,%d,%d\"\n",
755 dwRet, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
760 TCHAR thousandDelim[8];
761 TCHAR decimalDelim[8];
764 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, thousandDelim, 8);
765 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimalDelim, 8);
767 hShlwapi = GetModuleHandleA("shlwapi");
783 if (lstrcmp(thousandDelim, ",")==0 && lstrcmp(decimalDelim, ".")==0)
785 /* these tests are locale-dependent */
786 test_StrFormatByteSize64A();
787 test_StrFormatKBSizeA();
788 test_StrFormatKBSizeW();
791 /* language-dependent test */
792 if (PRIMARYLANGID(GetUserDefaultLangID()) != LANG_ENGLISH)
793 trace("Skipping StrFromTimeInterval test for non English language\n");
795 test_StrFromTimeIntervalA();
804 test_SHUnicodeToUnicode();