Commit bb3f6842 authored by Jactry Zeng's avatar Jactry Zeng Committed by Alexandre Julliard

ole32/tests: Test PropVariantCopy() with VT_UNKNOWN.

parent c3ac646a
......@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include "windows.h"
#include "wtypes.h"
#include "ddeml.h"
......@@ -298,10 +300,55 @@ static void test_validtypes(void)
}
}
struct unk_impl
{
IUnknown IUnknown_iface;
LONG ref;
};
static inline struct unk_impl *impl_from_IUnknown(IUnknown *iface)
{
return CONTAINING_RECORD(iface, struct unk_impl, IUnknown_iface);
}
static HRESULT WINAPI unk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
{
struct unk_impl *This = impl_from_IUnknown(iface);
if(winetest_debug > 1)
trace("Call to unk_QueryInterface()\n");
*ppv = &This->IUnknown_iface;
IUnknown_AddRef(iface);
return S_OK;
}
static ULONG WINAPI unk_AddRef(IUnknown *iface)
{
struct unk_impl *This = impl_from_IUnknown(iface);
if(winetest_debug > 1)
trace("Call to unk_AddRef()\n");
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI unk_Release(IUnknown *iface)
{
struct unk_impl *This = impl_from_IUnknown(iface);
if(winetest_debug > 1)
trace("Call to unk_Release()\n");
return InterlockedDecrement(&This->ref);
}
static const IUnknownVtbl unk_vtbl =
{
unk_QueryInterface,
unk_AddRef,
unk_Release
};
static void test_copy(void)
{
static char szTestString[] = "Test String";
static WCHAR wszTestString[] = {'T','e','s','t',' ','S','t','r','i','n','g',0};
struct unk_impl unk_obj = {{&unk_vtbl}, 1};
PROPVARIANT propvarSrc;
PROPVARIANT propvarDst;
HRESULT hr;
......@@ -334,6 +381,17 @@ static void test_copy(void)
hr = PropVariantClear(&propvarDst);
ok(hr == S_OK, "PropVariantClear(...VT_LPSTR...) failed\n");
memset(&propvarSrc, 0, sizeof(propvarSrc));
propvarSrc.vt = VT_UNKNOWN;
U(propvarSrc).punkVal = &unk_obj.IUnknown_iface;
hr = PropVariantCopy(&propvarDst, &propvarSrc);
ok(hr == S_OK, "PropVariantCopy(...VT_UNKNOWN...) failed: 0x%08x.\n", hr);
ok(U(propvarDst).punkVal == &unk_obj.IUnknown_iface, "Got wrong IUnknown pointer\n");
ok(unk_obj.ref == 2, "got wrong refcount: %d.\n", unk_obj.ref);
hr = PropVariantClear(&propvarDst);
ok(hr == S_OK, "PropVariantClear(...VT_UNKNOWN...) failed: 0x%08x.\n", hr);
ok(unk_obj.ref == 1, "got wrong refcount: %d.\n", unk_obj.ref);
memset(&propvarSrc, 0, sizeof(propvarSrc));
}
struct _PMemoryAllocator_vtable {
......
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