Commit 598f3f06 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

oleaut32/tests: Test for internal safearray data layout.

parent a4e0fc95
......@@ -2003,6 +2003,63 @@ static void test_SafeArrayDestroyData (void)
ok(hres == S_OK, "SAD failed, error code %x.\n", hres);
}
static void test_safearray_layout(void)
{
IRecordInfoImpl *irec;
IRecordInfo *record;
GUID guid, *guidptr;
SAFEARRAYBOUND sab;
SAFEARRAY *sa;
DWORD *dwptr;
HRESULT hr;
sab.lLbound = 0;
sab.cElements = 10;
/* GUID field */
sa = SafeArrayCreate(VT_UNKNOWN, 1, &sab);
ok(sa != NULL, "got %p\n", sa);
guidptr = (GUID*)sa - 1;
ok(IsEqualIID(guidptr, &IID_IUnknown), "got %s\n", wine_dbgstr_guid(guidptr));
hr = SafeArraySetIID(sa, &IID_IDispatch);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(IsEqualIID(guidptr, &IID_IDispatch), "got %s\n", wine_dbgstr_guid(guidptr));
memcpy(guidptr, &IID_IUnknown, sizeof(GUID));
hr = SafeArrayGetIID(sa, &guid);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(IsEqualIID(&guid, &IID_IUnknown), "got %s\n", wine_dbgstr_guid(&guid));
hr = SafeArrayDestroy(sa);
ok(hr == S_OK, "got 0x%08x\n", hr);
/* VARTYPE field */
sa = SafeArrayCreate(VT_UI1, 1, &sab);
ok(sa != NULL, "got %p\n", sa);
dwptr = (DWORD*)sa - 1;
ok(*dwptr == VT_UI1, "got %d\n", *dwptr);
hr = SafeArrayDestroy(sa);
ok(hr == S_OK, "got 0x%08x\n", hr);
/* IRecordInfo pointer */
irec = IRecordInfoImpl_Construct();
irec->ref = 1;
sa = pSafeArrayCreateEx(VT_RECORD, 1, &sab, &irec->IRecordInfo_iface);
ok(sa != NULL, "failed to create array\n");
record = *((IRecordInfo**)sa - 1);
ok(record == &irec->IRecordInfo_iface, "got %p\n", record);
hr = SafeArrayDestroy(sa);
ok(hr == S_OK, "got 0x%08x\n", hr);
IRecordInfo_Release(&irec->IRecordInfo_iface);
}
START_TEST(safearray)
{
hOleaut32 = GetModuleHandleA("oleaut32.dll");
......@@ -2035,4 +2092,5 @@ START_TEST(safearray)
test_SafeArrayGetPutElement_IUnknown();
test_SafeArrayRedim_IUnknown();
test_SafeArrayGetPutElement_VARIANT();
test_safearray_layout();
}
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