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
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
);
44 static void test_StrRetToStringNA(void)
46 trace("StrRetToStringNAW is Ascii\n");
50 static void test_StrRetToStringNW(void)
52 static const WCHAR szTestW
[] = { 'T','e','s','t','\0' };
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. */
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
);
97 hShell32
= GetModuleHandleA("shell32.dll");
99 pStrRetToStrNAW
= (void*)GetProcAddress(hShell32
, (LPSTR
)96);
102 if (!(GetVersion() & 0x80000000))
103 test_StrRetToStringNW();
105 test_StrRetToStringNA();