shell32/tests: Add DBCS file name tests for DragQueryFile.
[wine.git] / dlls / shell32 / tests / string.c
blobd1d621d9577b953c9f4f950cacc7d8d62b299939
1 /*
2 * Unit tests for shell32 string operations
4 * Copyright 2004 Jon Griffiths
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <stdio.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "wtypes.h"
27 #include "shellapi.h"
28 #include "shtypes.h"
29 #include "objbase.h"
31 #include "wine/test.h"
33 static HMODULE hShell32;
34 static BOOL (WINAPI *pStrRetToStrNAW)(LPVOID,DWORD,LPSTRRET,const ITEMIDLIST *);
36 static WCHAR *CoDupStrW(const char* src)
38 INT len = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0);
39 WCHAR* szTemp = CoTaskMemAlloc(len * sizeof(WCHAR));
40 MultiByteToWideChar(CP_ACP, 0, src, -1, szTemp, len);
41 return szTemp;
44 static void test_StrRetToStringNA(void)
46 trace("StrRetToStringNAW is Ascii\n");
47 /* FIXME */
50 static void test_StrRetToStringNW(void)
52 static const WCHAR szTestW[] = { 'T','e','s','t','\0' };
53 ITEMIDLIST iidl[10];
54 WCHAR buff[128];
55 STRRET strret;
56 BOOL ret;
58 trace("StrRetToStringNAW is Unicode\n");
60 strret.uType = STRRET_WSTR;
61 U(strret).pOleStr = CoDupStrW("Test");
62 memset(buff, 0xff, sizeof(buff));
63 ret = pStrRetToStrNAW(buff, ARRAY_SIZE(buff), &strret, NULL);
64 ok(ret == TRUE && !wcscmp(buff, szTestW),
65 "STRRET_WSTR: dup failed, ret=%d\n", ret);
67 strret.uType = STRRET_CSTR;
68 lstrcpyA(U(strret).cStr, "Test");
69 memset(buff, 0xff, sizeof(buff));
70 ret = pStrRetToStrNAW(buff, ARRAY_SIZE(buff), &strret, NULL);
71 ok(ret == TRUE && !wcscmp(buff, szTestW),
72 "STRRET_CSTR: dup failed, ret=%d\n", ret);
74 strret.uType = STRRET_OFFSET;
75 U(strret).uOffset = 1;
76 strcpy((char*)&iidl, " Test");
77 memset(buff, 0xff, sizeof(buff));
78 ret = pStrRetToStrNAW(buff, ARRAY_SIZE(buff), &strret, iidl);
79 ok(ret == TRUE && !wcscmp(buff, szTestW),
80 "STRRET_OFFSET: dup failed, ret=%d\n", ret);
82 /* The next test crashes on W2K, WinXP and W2K3, so we don't test. */
83 if (0)
85 /* Invalid dest - should return FALSE, except NT4 does not, so we don't check. */
86 strret.uType = STRRET_WSTR;
87 U(strret).pOleStr = CoDupStrW("Test");
88 pStrRetToStrNAW(NULL, ARRAY_SIZE(buff), &strret, NULL);
89 trace("NULL dest: ret=%d\n", ret);
93 START_TEST(string)
95 CoInitialize(0);
97 hShell32 = GetModuleHandleA("shell32.dll");
99 pStrRetToStrNAW = (void*)GetProcAddress(hShell32, (LPSTR)96);
100 if (pStrRetToStrNAW)
102 if (!(GetVersion() & 0x80000000))
103 test_StrRetToStringNW();
104 else
105 test_StrRetToStringNA();
108 CoUninitialize();