Commit 6e92fca9 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

- Fix PropVariantCopy for VT_LPSTR and VT_LPWSTR.

- Test case VT_BSTR, VT_LPSTR and VT_LPWSTR.
parent ab1866be
/*
* OLE2 library
*
......@@ -2426,8 +2425,11 @@ HRESULT WINAPI PropVariantClear(PROPVARIANT * pvar) /* [in/out] */
CoTaskMemFree(pvar->u.blob.pBlobData);
break;
case VT_BSTR:
FIXME("Need to load OLEAUT32 for SysFreeString\n");
/* SysFreeString(pvar->u.bstrVal); */
if (pvar->u.bstrVal)
{
FIXME("Need to load OLEAUT32 for SysFreeString\n");
/* SysFreeString(pvar->u.bstrVal); */
}
break;
case VT_CF:
if (pvar->u.pclipdata)
......@@ -2496,13 +2498,13 @@ HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, /* [out] */
break;
case VT_LPSTR:
len = strlen(pvarSrc->u.pszVal);
pvarDest->u.pszVal = CoTaskMemAlloc(len);
CopyMemory(pvarDest->u.pszVal, pvarSrc->u.pszVal, len);
pvarDest->u.pszVal = CoTaskMemAlloc((len+1)*sizeof(CHAR));
CopyMemory(pvarDest->u.pszVal, pvarSrc->u.pszVal, (len+1)*sizeof(CHAR));
break;
case VT_LPWSTR:
len = lstrlenW(pvarSrc->u.pwszVal);
pvarDest->u.pwszVal = CoTaskMemAlloc(len);
CopyMemory(pvarDest->u.pwszVal, pvarSrc->u.pwszVal, len);
pvarDest->u.pwszVal = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
CopyMemory(pvarDest->u.pwszVal, pvarSrc->u.pwszVal, (len+1)*sizeof(WCHAR));
break;
case VT_BLOB:
case VT_BLOB_OBJECT:
......
......@@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = ole32.dll
IMPORTS = ole32 kernel32 ntdll
IMPORTS = oleaut32 ole32 kernel32 ntdll
EXTRALIBS = -luuid
CTESTS = \
......
......@@ -18,10 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windows.h"
/* not present in Wine yet */
/*#include "propidl.h"*/
WINOLEAPI PropVariantClear(PROPVARIANT*);
WINOLEAPI PropVariantCopy(PROPVARIANT*, const PROPVARIANT*);
#include "wine/test.h"
......@@ -160,7 +163,46 @@ static void test_validtypes()
}
}
static void test_copy()
{
static const char szTestString[] = "Test String";
static const WCHAR wszTestString[] = {'T','e','s','t',' ','S','t','r','i','n','g',0};
PROPVARIANT propvarSrc;
PROPVARIANT propvarDst;
HRESULT hr;
propvarSrc.vt = VT_BSTR;
propvarSrc.u.bstrVal = SysAllocString(wszTestString);
hr = PropVariantCopy(&propvarDst, &propvarSrc);
ok(hr == S_OK, "PropVariantCopy(...VT_BSTR...) failed\n");
ok(!lstrcmpW(propvarSrc.u.bstrVal, propvarDst.u.bstrVal), "BSTR not copied properly\n");
hr = PropVariantClear(&propvarSrc);
ok(hr == S_OK, "PropVariantClear(...VT_BSTR...) failed\n");
hr = PropVariantClear(&propvarDst);
ok(hr == S_OK, "PropVariantClear(...VT_BSTR...) failed\n");
propvarSrc.vt = VT_LPWSTR;
propvarSrc.u.pwszVal = (LPWSTR)wszTestString;
hr = PropVariantCopy(&propvarDst, &propvarSrc);
ok(hr == S_OK, "PropVariantCopy(...VT_LPWSTR...) failed\n");
ok(!lstrcmpW(propvarSrc.u.pwszVal, propvarDst.u.pwszVal), "Wide string not copied properly\n");
hr = PropVariantClear(&propvarDst);
ok(hr == S_OK, "PropVariantClear(...VT_LPWSTR...) failed\n");
memset(&propvarSrc, 0, sizeof(propvarSrc));
propvarSrc.vt = VT_LPSTR;
propvarSrc.u.pszVal = (LPSTR)szTestString;
hr = PropVariantCopy(&propvarDst, &propvarSrc);
ok(hr == S_OK, "PropVariantCopy(...VT_LPSTR...) failed\n");
ok(!strcmp(propvarSrc.u.pszVal, propvarDst.u.pszVal), "String not copied properly\n");
hr = PropVariantClear(&propvarDst);
ok(hr == S_OK, "PropVariantClear(...VT_LPSTR...) failed\n");
memset(&propvarSrc, 0, sizeof(propvarSrc));
}
START_TEST(propvariant)
{
test_validtypes();
test_copy();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment