Commit b07ebe68 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

oleaut32/tests: Some tests for SafeArrayDestroyData().

parent 395b9c32
......@@ -1965,40 +1965,99 @@ static void test_SafeArrayChangeTypeEx(void)
static void test_SafeArrayDestroyData (void)
{
SAFEARRAYBOUND sab;
SAFEARRAYBOUND sab[2];
SAFEARRAY *sa;
HRESULT hres;
int value = 0xdeadbeef;
LONG index[1];
void *temp_pvData;
USHORT features;
sab.lLbound = 0;
sab.cElements = 10;
sa = SafeArrayCreate(VT_INT, 1, &sab);
sab[0].lLbound = 0;
sab[0].cElements = 10;
sa = SafeArrayCreate(VT_INT, 1, sab);
ok(sa != NULL, "Create() failed.\n");
if (!sa)
return;
ok(sa->fFeatures == FADF_HAVEVARTYPE, "got 0x%x\n", sa->fFeatures);
index[0] = 1;
SafeArrayPutElement (sa, index, &value);
/* SafeArrayDestroyData shouldn't free pvData if FADF_STATIC is set. */
sa->fFeatures |= FADF_STATIC;
features = (sa->fFeatures |= FADF_STATIC);
temp_pvData = sa->pvData;
hres = SafeArrayDestroyData(sa);
ok(hres == S_OK, "SADData FADF_STATIC failed, error code %x.\n",hres);
ok(features == sa->fFeatures, "got 0x%x\n", sa->fFeatures);
ok(sa->pvData == temp_pvData, "SADData FADF_STATIC: pvData=%p, expected %p (fFeatures = %d).\n",
sa->pvData, temp_pvData, sa->fFeatures);
SafeArrayGetElement (sa, index, &value);
ok(value == 0, "Data not cleared after SADData\n");
/* Clear FADF_STATIC, now really destroy the data. */
sa->fFeatures ^= FADF_STATIC;
features = (sa->fFeatures ^= FADF_STATIC);
hres = SafeArrayDestroyData(sa);
ok(hres == S_OK, "SADData !FADF_STATIC failed, error code %x.\n",hres);
ok(features == sa->fFeatures, "got 0x%x\n", sa->fFeatures);
ok(sa->pvData == NULL, "SADData !FADF_STATIC: pvData=%p, expected NULL.\n", sa->pvData);
hres = SafeArrayDestroy(sa);
ok(hres == S_OK, "SAD failed, error code %x.\n", hres);
/* two dimensions */
sab[0].lLbound = 0;
sab[0].cElements = 10;
sab[1].lLbound = 0;
sab[1].cElements = 10;
sa = SafeArrayCreate(VT_INT, 2, sab);
ok(sa != NULL, "Create() failed.\n");
ok(sa->fFeatures == FADF_HAVEVARTYPE, "got 0x%x\n", sa->fFeatures);
features = sa->fFeatures;
hres = SafeArrayDestroyData(sa);
ok(hres == S_OK, "got 0x%08x\n",hres);
ok(features == sa->fFeatures, "got 0x%x\n", sa->fFeatures);
SafeArrayDestroy(sa);
/* try to destroy data from descriptor */
hres = SafeArrayAllocDescriptor(1, &sa);
ok(hres == S_OK, "got 0x%08x\n", hres);
ok(sa->fFeatures == 0, "got 0x%x\n", sa->fFeatures);
hres = SafeArrayDestroyData(sa);
ok(hres == S_OK, "got 0x%08x\n", hres);
ok(sa->fFeatures == 0, "got 0x%x\n", sa->fFeatures);
hres = SafeArrayDestroyDescriptor(sa);
ok(hres == S_OK, "got 0x%08x\n", hres);
hres = SafeArrayAllocDescriptor(2, &sa);
ok(hres == S_OK, "got 0x%08x\n", hres);
ok(sa->fFeatures == 0, "got 0x%x\n", sa->fFeatures);
hres = SafeArrayDestroyData(sa);
ok(hres == S_OK, "got 0x%08x\n", hres);
ok(sa->fFeatures == 0, "got 0x%x\n", sa->fFeatures);
hres = SafeArrayDestroyDescriptor(sa);
ok(hres == S_OK, "got 0x%08x\n", hres);
/* vector case */
sa = SafeArrayCreateVector(VT_I4, 0, 10);
ok(sa != NULL, "got %p\n", sa);
ok(sa->fFeatures == (FADF_CREATEVECTOR|FADF_HAVEVARTYPE), "got 0x%x\n", sa->fFeatures);
ok(sa->pvData != NULL, "got %p\n", sa->pvData);
hres = SafeArrayDestroyData(sa);
ok(hres == S_OK, "got 0x%08x\n", hres);
todo_wine
ok(sa->fFeatures == FADF_HAVEVARTYPE, "got 0x%x\n", sa->fFeatures);
ok(sa->pvData != NULL, "got %p\n", sa->pvData);
/* There seems to be a bug on windows, especially visible on 64bit systems,
probably double-free of similar issue. */
sa->pvData = NULL;
SafeArrayDestroy(sa);
}
static void test_safearray_layout(void)
......
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