2004-02-10 03:19:03 +01:00
|
|
|
/*
|
|
|
|
* Unit tests for shell32 string operations
|
|
|
|
*
|
|
|
|
* Copyright 2004 Jon Griffiths
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-02-10 03:19:03 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define WINE_NOWINSOCK
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wtypes.h"
|
|
|
|
#include "shellapi.h"
|
|
|
|
#include "shtypes.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
static HMODULE hShell32;
|
2015-10-21 13:43:30 +02:00
|
|
|
static BOOL (WINAPI *pStrRetToStrNAW)(LPVOID,DWORD,LPSTRRET,const ITEMIDLIST *);
|
2004-02-10 03:19:03 +01:00
|
|
|
|
|
|
|
static WCHAR *CoDupStrW(const char* src)
|
|
|
|
{
|
|
|
|
INT len = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0);
|
2008-11-05 23:00:50 +01:00
|
|
|
WCHAR* szTemp = CoTaskMemAlloc(len * sizeof(WCHAR));
|
2004-02-10 03:19:03 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, src, -1, szTemp, len);
|
|
|
|
return szTemp;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_StrRetToStringNA(void)
|
|
|
|
{
|
|
|
|
trace("StrRetToStringNAW is Ascii\n");
|
|
|
|
/* FIXME */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_StrRetToStringNW(void)
|
|
|
|
{
|
|
|
|
static const WCHAR szTestW[] = { 'T','e','s','t','\0' };
|
|
|
|
ITEMIDLIST iidl[10];
|
|
|
|
WCHAR buff[128];
|
|
|
|
STRRET strret;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
trace("StrRetToStringNAW is Unicode\n");
|
|
|
|
|
|
|
|
strret.uType = STRRET_WSTR;
|
2006-11-23 21:35:32 +01:00
|
|
|
U(strret).pOleStr = CoDupStrW("Test");
|
2004-02-10 03:19:03 +01:00
|
|
|
memset(buff, 0xff, sizeof(buff));
|
2018-06-15 00:04:42 +02:00
|
|
|
ret = pStrRetToStrNAW(buff, ARRAY_SIZE(buff), &strret, NULL);
|
2020-01-26 10:57:37 +01:00
|
|
|
ok(ret == TRUE && !wcscmp(buff, szTestW),
|
2004-02-10 03:19:03 +01:00
|
|
|
"STRRET_WSTR: dup failed, ret=%d\n", ret);
|
|
|
|
|
|
|
|
strret.uType = STRRET_CSTR;
|
2006-11-23 21:35:32 +01:00
|
|
|
lstrcpyA(U(strret).cStr, "Test");
|
2004-02-10 03:19:03 +01:00
|
|
|
memset(buff, 0xff, sizeof(buff));
|
2018-06-15 00:04:42 +02:00
|
|
|
ret = pStrRetToStrNAW(buff, ARRAY_SIZE(buff), &strret, NULL);
|
2020-01-26 10:57:37 +01:00
|
|
|
ok(ret == TRUE && !wcscmp(buff, szTestW),
|
2004-02-10 03:19:03 +01:00
|
|
|
"STRRET_CSTR: dup failed, ret=%d\n", ret);
|
|
|
|
|
|
|
|
strret.uType = STRRET_OFFSET;
|
2006-11-23 21:35:32 +01:00
|
|
|
U(strret).uOffset = 1;
|
2004-02-10 03:19:03 +01:00
|
|
|
strcpy((char*)&iidl, " Test");
|
|
|
|
memset(buff, 0xff, sizeof(buff));
|
2018-06-15 00:04:42 +02:00
|
|
|
ret = pStrRetToStrNAW(buff, ARRAY_SIZE(buff), &strret, iidl);
|
2020-01-26 10:57:37 +01:00
|
|
|
ok(ret == TRUE && !wcscmp(buff, szTestW),
|
2004-02-10 03:19:03 +01:00
|
|
|
"STRRET_OFFSET: dup failed, ret=%d\n", ret);
|
|
|
|
|
2005-07-24 19:12:06 +02:00
|
|
|
/* The next test crashes on W2K, WinXP and W2K3, so we don't test. */
|
2014-01-22 22:32:31 +01:00
|
|
|
if (0)
|
|
|
|
{
|
2005-03-22 19:19:13 +01:00
|
|
|
/* Invalid dest - should return FALSE, except NT4 does not, so we don't check. */
|
2004-02-10 03:19:03 +01:00
|
|
|
strret.uType = STRRET_WSTR;
|
2006-11-23 21:35:32 +01:00
|
|
|
U(strret).pOleStr = CoDupStrW("Test");
|
2018-06-15 00:04:42 +02:00
|
|
|
pStrRetToStrNAW(NULL, ARRAY_SIZE(buff), &strret, NULL);
|
2005-03-22 19:19:13 +01:00
|
|
|
trace("NULL dest: ret=%d\n", ret);
|
2014-01-22 22:32:31 +01:00
|
|
|
}
|
2004-02-10 03:19:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(string)
|
|
|
|
{
|
|
|
|
CoInitialize(0);
|
|
|
|
|
2007-08-15 21:00:06 +02:00
|
|
|
hShell32 = GetModuleHandleA("shell32.dll");
|
2004-02-10 03:19:03 +01:00
|
|
|
|
|
|
|
pStrRetToStrNAW = (void*)GetProcAddress(hShell32, (LPSTR)96);
|
|
|
|
if (pStrRetToStrNAW)
|
|
|
|
{
|
|
|
|
if (!(GetVersion() & 0x80000000))
|
|
|
|
test_StrRetToStringNW();
|
|
|
|
else
|
|
|
|
test_StrRetToStringNA();
|
|
|
|
}
|
2008-05-19 17:04:48 +02:00
|
|
|
|
|
|
|
CoUninitialize();
|
2004-02-10 03:19:03 +01:00
|
|
|
}
|