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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
26 #define WINE_NOWINSOCK
34 #include "wine/test.h"
36 static HMODULE hShell32;
37 static HRESULT (WINAPI *pStrRetToStrNAW)(LPVOID,DWORD,LPSTRRET,const ITEMIDLIST *);
39 static WCHAR *CoDupStrW(const char* src)
41 INT len = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0);
42 WCHAR* szTemp = (WCHAR*)CoTaskMemAlloc(len * sizeof(WCHAR));
43 MultiByteToWideChar(CP_ACP, 0, src, -1, szTemp, len);
47 static inline int strcmpW(const WCHAR *str1, const WCHAR *str2)
49 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
53 static void test_StrRetToStringNA(void)
55 trace("StrRetToStringNAW is Ascii\n");
59 static void test_StrRetToStringNW(void)
61 static const WCHAR szTestW[] = { 'T','e','s','t','\0' };
67 trace("StrRetToStringNAW is Unicode\n");
69 strret.uType = STRRET_WSTR;
70 strret.u.pOleStr = CoDupStrW("Test");
71 memset(buff, 0xff, sizeof(buff));
72 ret = pStrRetToStrNAW(buff, sizeof(buff)/sizeof(WCHAR), &strret, NULL);
73 ok(ret == TRUE && !strcmpW(buff, szTestW),
74 "STRRET_WSTR: dup failed, ret=%d\n", ret);
76 strret.uType = STRRET_CSTR;
77 lstrcpyA(strret.u.cStr, "Test");
78 memset(buff, 0xff, sizeof(buff));
79 ret = pStrRetToStrNAW(buff, sizeof(buff)/sizeof(WCHAR), &strret, NULL);
80 ok(ret == TRUE && !strcmpW(buff, szTestW),
81 "STRRET_CSTR: dup failed, ret=%d\n", ret);
83 strret.uType = STRRET_OFFSET;
85 strcpy((char*)&iidl, " Test");
86 memset(buff, 0xff, sizeof(buff));
87 ret = pStrRetToStrNAW(buff, sizeof(buff)/sizeof(WCHAR), &strret, iidl);
88 ok(ret == TRUE && !strcmpW(buff, szTestW),
89 "STRRET_OFFSET: dup failed, ret=%d\n", ret);
91 /* Invalid dest - returns FALSE */
92 strret.uType = STRRET_WSTR;
93 strret.u.pOleStr = CoDupStrW("Test");
94 ret = pStrRetToStrNAW(NULL, sizeof(buff)/sizeof(WCHAR), &strret, NULL);
95 ok(ret == FALSE, "NULL dest: expected FALSE, ret=%d\n", ret);
103 hShell32 = LoadLibraryA("shell32.dll");
107 pStrRetToStrNAW = (void*)GetProcAddress(hShell32, (LPSTR)96);
110 if (!(GetVersion() & 0x80000000))
111 test_StrRetToStringNW();
113 test_StrRetToStringNA();