Fix the case of product and company names.
[wine] / dlls / oleaut32 / tests / safearray.c
1 /*
2  * SafeArray test program
3  *
4  * Copyright 2002 Marcus Meissner
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include <stdarg.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <math.h>
26 #include <float.h>
27 #include <time.h>
28
29 #include "wine/test.h"
30 #include "windef.h"
31 #include "winbase.h"
32 #include "winuser.h"
33 #include "wingdi.h"
34 #include "winnls.h"
35 #include "winsock.h"
36 #include "winerror.h"
37 #include "winnt.h"
38
39 #include "wtypes.h"
40 #include "oleauto.h"
41
42 static HRESULT (WINAPI *pSafeArrayAllocDescriptorEx)(VARTYPE,UINT,struct tagSAFEARRAY**)=NULL;
43 static HRESULT (WINAPI *pSafeArrayCopyData)(struct tagSAFEARRAY*,struct tagSAFEARRAY*)=NULL;
44 static HRESULT (WINAPI *pSafeArrayGetIID)(struct tagSAFEARRAY*,GUID*)=NULL;
45 static HRESULT (WINAPI *pSafeArraySetIID)(struct tagSAFEARRAY*,REFGUID)=NULL;
46 static HRESULT (WINAPI *pSafeArrayGetVartype)(struct tagSAFEARRAY*,VARTYPE*)=NULL;
47
48 #define VARTYPE_NOT_SUPPORTED 0
49 static struct {
50         VARTYPE vt;    /* VT */
51         UINT elemsize; /* elementsize by VT */
52         UINT expflags; /* fFeatures from SafeArrayAllocDescriptorEx */
53         UINT addflags; /* additional fFeatures from SafeArrayCreate */
54 } vttypes[] = {
55 {VT_EMPTY,    VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
56 {VT_NULL,     VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
57 {VT_I2,       2,                    FADF_HAVEVARTYPE,0},
58 {VT_I4,       4,                    FADF_HAVEVARTYPE,0},
59 {VT_R4,       4,                    FADF_HAVEVARTYPE,0},
60 {VT_R8,       8,                    FADF_HAVEVARTYPE,0},
61 {VT_CY,       8,                    FADF_HAVEVARTYPE,0},
62 {VT_DATE,     8,                    FADF_HAVEVARTYPE,0},
63 {VT_BSTR,     sizeof(BSTR),         FADF_HAVEVARTYPE,FADF_BSTR},
64 {VT_DISPATCH, sizeof(LPDISPATCH),   FADF_HAVEIID,    FADF_DISPATCH},
65 {VT_ERROR,    4,                    FADF_HAVEVARTYPE,0},
66 {VT_BOOL,     2,                    FADF_HAVEVARTYPE,0},
67 {VT_VARIANT,  sizeof(VARIANT),      FADF_HAVEVARTYPE,FADF_VARIANT},
68 {VT_UNKNOWN,  sizeof(LPUNKNOWN),    FADF_HAVEIID,    FADF_UNKNOWN},
69 {VT_DECIMAL,  sizeof(DECIMAL),      FADF_HAVEVARTYPE,0},
70 {15,          VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0}, /* no VT_xxx */
71 {VT_I1,       1,                    FADF_HAVEVARTYPE,0},
72 {VT_UI1,      1,                    FADF_HAVEVARTYPE,0},
73 {VT_UI2,      2,                    FADF_HAVEVARTYPE,0},
74 {VT_UI4,      4,                    FADF_HAVEVARTYPE,0},
75 {VT_I8,       VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
76 {VT_UI8,      VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
77 {VT_INT,      sizeof(INT),          FADF_HAVEVARTYPE,0},
78 {VT_UINT,     sizeof(UINT),         FADF_HAVEVARTYPE,0},
79 {VT_VOID,     VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
80 {VT_HRESULT,  VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
81 {VT_PTR,      VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
82 {VT_SAFEARRAY,VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
83 {VT_CARRAY,   VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
84 {VT_USERDEFINED,VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
85 {VT_LPSTR,    VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
86 {VT_LPWSTR,   VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
87 {VT_FILETIME, VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
88 {VT_RECORD,   VARTYPE_NOT_SUPPORTED,FADF_RECORD,0},
89 {VT_BLOB,     VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
90 {VT_STREAM,   VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
91 {VT_STORAGE,  VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
92 {VT_STREAMED_OBJECT,VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
93 {VT_STORED_OBJECT,VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
94 {VT_BLOB_OBJECT,VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
95 {VT_CF,       VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
96 {VT_CLSID,    VARTYPE_NOT_SUPPORTED,FADF_HAVEVARTYPE,0},
97 };
98
99 START_TEST(safearray)
100 {
101         HMODULE hdll;
102         SAFEARRAY       *a, b, *c;
103         unsigned int    i;
104         long            indices[2];
105         HRESULT         hres;
106         SAFEARRAYBOUND  bound, bounds[2];
107         VARIANT         v;
108         LPVOID          data;
109         IID             iid;
110         VARTYPE         vt;
111         LONG            l;
112         unsigned char   *ptr1, *ptr2;
113
114     hdll=LoadLibraryA("oleaut32.dll");
115     pSafeArrayAllocDescriptorEx=(void*)GetProcAddress(hdll,"SafeArrayAllocDescriptorEx");
116     pSafeArrayCopyData=(void*)GetProcAddress(hdll,"SafeArrayCopyData");
117     pSafeArrayGetIID=(void*)GetProcAddress(hdll,"SafeArrayGetIID");
118     pSafeArraySetIID=(void*)GetProcAddress(hdll,"SafeArraySetIID");
119     pSafeArrayGetVartype=(void*)GetProcAddress(hdll,"SafeArrayGetVartype");
120
121         hres = SafeArrayAllocDescriptor(0,&a);
122         ok(E_INVALIDARG == hres,"SAAD(0) failed with hres %lx",hres);
123
124         hres=SafeArrayAllocDescriptor(1,&a);
125         ok(S_OK == hres,"SAAD(1) failed with %lx",hres);
126
127         for (i=1;i<100;i++) {
128                 hres=SafeArrayAllocDescriptor(i,&a);
129                 ok(S_OK == hres,"SAAD(%d) failed with %lx",i,hres);
130                 
131                 ok(a->cDims == i,"a->cDims not initialised?");
132
133                 hres=SafeArrayDestroyDescriptor(a);
134                 ok(S_OK == hres,"SADD failed with %lx",hres);
135         }
136
137         hres=SafeArrayAllocDescriptor(65535,&a);
138         ok(S_OK == hres,"SAAD(65535) failed with %lx",hres);
139
140         hres=SafeArrayDestroyDescriptor(a);
141         ok(S_OK == hres,"SADD failed with %lx",hres);
142
143         hres=SafeArrayAllocDescriptor(65536,&a);
144         ok(E_INVALIDARG == hres,"SAAD(65536) failed with %lx",hres);
145
146         /* Crashes on Win95: SafeArrayAllocDescriptor(xxx,NULL) */
147         
148         bound.cElements = 1;
149         bound.lLbound   = 0;
150         a = SafeArrayCreate(-1, 1, &bound);
151         ok(NULL == a,"SAC(-1,1,[1,0]) not failed?");
152
153
154         bounds[0].cElements = 42;       bounds[0].lLbound =  1;
155         bounds[1].cElements =  2;       bounds[1].lLbound = 23;
156     a = SafeArrayCreate(VT_I4,2,bounds);
157     ok(a != NULL,"SAC(VT_INT32,2,...) failed.");
158
159         hres = SafeArrayGetLBound (a, 0, &l);
160         ok (hres == DISP_E_BADINDEX, "SAGLB 0 failed with %lx", hres);
161         hres = SafeArrayGetLBound (a, 1, &l);
162         ok (hres == S_OK, "SAGLB 1 failed with %lx", hres);
163         ok (l == 1, "SAGLB 1 returned %ld instead of 1", l);
164         hres = SafeArrayGetLBound (a, 2, &l);
165         ok (hres == S_OK, "SAGLB 2 failed with %lx", hres);
166         ok (l == 23, "SAGLB 2 returned %ld instead of 1", l);
167         hres = SafeArrayGetLBound (a, 3, &l);
168         ok (hres == DISP_E_BADINDEX, "SAGLB 3 failed with %lx", hres);
169
170         hres = SafeArrayGetUBound (a, 0, &l);
171         ok (hres == DISP_E_BADINDEX, "SAGUB 0 failed with %lx", hres);
172         hres = SafeArrayGetUBound (a, 1, &l);
173         ok (hres == S_OK, "SAGUB 1 failed with %lx", hres);
174         ok (l == 42, "SAGUB 1 returned %ld instead of 1", l);
175         hres = SafeArrayGetUBound (a, 2, &l);
176         ok (hres == S_OK, "SAGUB 2 failed with %lx", hres);
177         ok (l == 24, "SAGUB 2 returned %ld instead of 24", l);
178         hres = SafeArrayGetUBound (a, 3, &l);
179         ok (hres == DISP_E_BADINDEX, "SAGUB 3 failed with %lx", hres);
180
181         i = SafeArrayGetDim(a);
182         ok(i == 2, "getdims of 2 din array returned %d",i);
183
184         indices[0] = 0;
185         indices[1] = 23;
186         hres = SafeArrayGetElement(a, indices, &i);
187         ok(DISP_E_BADINDEX == hres,"SAGE failed [0,23], hres 0x%lx",hres);
188
189         indices[0] = 1;
190         indices[1] = 22;
191         hres = SafeArrayGetElement(a, indices, &i);
192         ok(DISP_E_BADINDEX == hres,"SAGE failed [1,22], hres 0x%lx",hres);
193
194         indices[0] = 1;
195         indices[1] = 23;
196         hres = SafeArrayGetElement(a, indices, &i);
197         ok(S_OK == hres,"SAGE failed [1,23], hres 0x%lx",hres);
198
199         indices[0] = 1;
200         indices[1] = 25;
201         hres = SafeArrayGetElement(a, indices, &i);
202         ok(DISP_E_BADINDEX == hres,"SAGE failed [1,24], hres 0x%lx",hres);
203
204         indices[0] = 3;
205         indices[1] = 23;
206         hres = SafeArrayGetElement(a, indices, &i);
207         ok(S_OK == hres,"SAGE failed [42,23], hres 0x%lx",hres);
208
209         hres = SafeArrayAccessData(a, (void**)&ptr1);
210         ok(S_OK == hres, "SAAD failed with 0x%lx", hres);
211
212         indices[0] = 3;
213         indices[1] = 23;
214         hres = SafeArrayPtrOfIndex(a, indices, (void**)&ptr2);
215         ok(S_OK == hres,"SAPOI failed [1,23], hres 0x%lx",hres);
216         ok(ptr2 - ptr1 == 8,"ptr difference is not 8, but %d (%p vs %p)", ptr2-ptr1, ptr2, ptr1);
217
218         indices[0] = 3;
219         indices[1] = 24;
220         hres = SafeArrayPtrOfIndex(a, indices, (void**)&ptr2);
221         ok(S_OK == hres,"SAPOI failed [5,24], hres 0x%lx",hres);
222         ok(ptr2 - ptr1 == 176,"ptr difference is not 176, but %d (%p vs %p)", ptr2-ptr1, ptr2, ptr1);
223
224         indices[0] = 20;
225         indices[1] = 23;
226         hres = SafeArrayPtrOfIndex(a, indices, (void**)&ptr2);
227         ok(S_OK == hres,"SAPOI failed [20,23], hres 0x%lx",hres);
228         ok(ptr2 - ptr1 == 76,"ptr difference is not 176, but %d (%p vs %p)", ptr2-ptr1, ptr2, ptr1);
229
230         hres = SafeArrayUnaccessData(a);
231         ok(S_OK == hres, "SAUAD failed with 0x%lx", hres);
232
233         for (i=0;i<sizeof(vttypes)/sizeof(vttypes[0]);i++) {
234                 a = SafeArrayCreate(vttypes[i].vt, 1, &bound);
235                 ok(     ((a == NULL) && (vttypes[i].elemsize == 0)) ||
236                         ((a != NULL) && (vttypes[i].elemsize == a->cbElements)),
237                 "SAC(%d,1,[1,0]), result %ld, expected %d",vttypes[i].vt,(a?a->cbElements:0),vttypes[i].elemsize
238                 );
239         if (a!=NULL) {
240                         ok(a->fFeatures == (vttypes[i].expflags | vttypes[i].addflags),
241                "SAC of %d returned feature flags %x, expected %x",
242                vttypes[i].vt, a->fFeatures,
243                vttypes[i].expflags|vttypes[i].addflags);
244                 ok(SafeArrayGetElemsize(a) == vttypes[i].elemsize,
245                "SAGE for vt %d returned elemsize %d instead of expected %d",
246                vttypes[i].vt, SafeArrayGetElemsize(a),vttypes[i].elemsize);
247         }
248
249                 if (!a) continue;
250
251         if (pSafeArrayGetVartype) {
252             hres = pSafeArrayGetVartype(a, &vt);
253             ok(hres == S_OK, "SAGVT of arra y with vt %d failed with %lx", vttypes[i].vt, hres);
254             if (vttypes[i].vt == VT_DISPATCH) {
255                         /* Special case. Checked against Windows. */
256                         ok(vt == VT_UNKNOWN, "SAGVT of a        rray with VT_DISPATCH returned not VT_UNKNOWN, but %d", vt);
257             } else {
258                         ok(vt == vttypes[i].vt, "SAGVT of array with vt %d returned %d", vttypes[i].vt, vt);
259             }
260         }
261
262                 hres = SafeArrayCopy(a, &c);
263                 ok(hres == S_OK, "failed to copy safearray of vt %d with hres %lx", vttypes[i].vt, hres);
264
265                 ok(vttypes[i].elemsize == c->cbElements,"copy of SAC(%d,1,[1,0]), result %ld, expected %d",vttypes[i].vt,(c?c->cbElements:0),vttypes[i].elemsize
266                 );
267                 ok(c->fFeatures == (vttypes[i].expflags | vttypes[i].addflags),"SAC of %d returned feature flags %x, expected %x", vttypes[i].vt, c->fFeatures, vttypes[i].expflags|vttypes[i].addflags);
268                 ok(SafeArrayGetElemsize(c) == vttypes[i].elemsize,"SAGE for vt %d returned elemsize %d instead of expected %d",vttypes[i].vt, SafeArrayGetElemsize(c),vttypes[i].elemsize);
269
270         if (pSafeArrayGetVartype) {
271             hres = pSafeArrayGetVartype(c, &vt);
272             ok(hres == S_OK, "SAGVT of array with vt %d failed with %lx", vttypes[i].vt, hres);
273             if (vttypes[i].vt == VT_DISPATCH) {
274                 /* Special case. Checked against Windows. */
275                 ok(vt == VT_UNKNOWN, "SAGVT of array with VT_DISPATCH returned not VT_UNKNOWN, but %d", vt);
276             } else {
277                 ok(vt == vttypes[i].vt, "SAGVT of array with vt %d returned %d", vttypes[i].vt, vt);
278             }
279         }
280
281         if (pSafeArrayCopyData) {
282             hres = pSafeArrayCopyData(a, c);
283             ok(hres == S_OK, "failed to copy safearray data of vt %d with hres %lx", vttypes[i].vt, hres);
284
285             hres = SafeArrayDestroyData(c);
286             ok(hres == S_OK,"SADD of copy of array with vt %d failed with hres %lx", vttypes[i].vt, hres);
287         }
288
289                 hres = SafeArrayDestroy(a);
290                 ok(hres == S_OK,"SAD of array with vt %d failed with hres %lx", vttypes[i].vt, hres);
291         }
292
293         /* Test conversion of type|VT_ARRAY <-> VT_BSTR */
294         bound.lLbound = 0;
295         bound.cElements = 10;
296         a = SafeArrayCreate(VT_UI1, 1, &bound);
297         ok(a != NULL, "SAC failed.");
298         ok(S_OK == SafeArrayAccessData(a, &data),"SACD failed");
299         memcpy(data,"Hello World",10);
300         ok(S_OK == SafeArrayUnaccessData(a),"SAUD failed");
301         V_VT(&v) = VT_ARRAY|VT_UI1;
302         V_ARRAY(&v) = a;
303         hres = VariantChangeTypeEx(&v, &v, 0, 0, VT_BSTR);
304         ok(hres==S_OK, "CTE VT_ARRAY|VT_UI1 -> VT_BSTR failed with %lx",hres);
305         ok(V_VT(&v) == VT_BSTR,"CTE VT_ARRAY|VT_UI1 -> VT_BSTR did not return VT_BSTR, but %d.",V_VT(&v));
306         ok(V_BSTR(&v)[0] == 0x6548,"First letter are not 'He', but %x", V_BSTR(&v)[0]);
307
308         /* check locking functions */
309         a = SafeArrayCreate(VT_I4, 1, &bound);
310         ok(a!=NULL,"SAC should not fail");
311
312         hres = SafeArrayAccessData(a, &data);
313         ok(hres == S_OK,"SAAD failed with hres %lx",hres);
314
315         hres = SafeArrayDestroy(a);
316         ok(hres == DISP_E_ARRAYISLOCKED,"locked safe array destroy not failed with DISP_E_ARRAYISLOCKED, but with hres %lx", hres);
317
318         hres = SafeArrayDestroyData(a);
319         ok(hres == DISP_E_ARRAYISLOCKED,"locked safe array destroy data not failed with DISP_E_ARRAYISLOCKED, but with hres %lx", hres);
320
321         hres = SafeArrayDestroyDescriptor(a);
322         ok(hres == DISP_E_ARRAYISLOCKED,"locked safe array destroy descriptor not failed with DISP_E_ARRAYISLOCKED, but with hres %lx", hres);
323
324         hres = SafeArrayUnaccessData(a);
325         ok(hres == S_OK,"SAUD failed after lock/destroy test");
326
327         hres = SafeArrayDestroy(a);
328         ok(hres == S_OK,"SAD failed after lock/destroy test");
329
330         /* Test if we need to destroy data before descriptor */
331         a = SafeArrayCreate(VT_I4, 1, &bound);
332         ok(a!=NULL,"SAC should not fail");
333         hres = SafeArrayDestroyDescriptor(a);
334         ok(hres == S_OK,"SADD with data in array failed with hres %lx",hres);
335
336
337         /* IID functions */
338         /* init a small stack safearray */
339     if (pSafeArraySetIID) {
340         memset(&b, 0, sizeof(b));
341         b.cDims = 1;
342         memset(&iid, 0x42, sizeof(IID));
343         hres = pSafeArraySetIID(&b,&iid);
344         ok(hres == E_INVALIDARG,"SafeArraySetIID of non IID capable safearray did not return E_INVALIDARG, but %lx",hres);
345
346         hres = SafeArrayAllocDescriptor(1,&a);
347         ok((a->fFeatures & FADF_HAVEIID) == 0,"newly allocated descriptor with SAAD should not have FADF_HAVEIID");
348         hres = pSafeArraySetIID(a,&iid);
349         ok(hres == E_INVALIDARG,"SafeArraySetIID of newly allocated descriptor with SAAD should return E_INVALIDARG, but %lx",hres);
350     }
351
352     if (!pSafeArrayAllocDescriptorEx)
353         return;
354
355         for (i=0;i<sizeof(vttypes)/sizeof(vttypes[0]);i++) {
356                 hres = pSafeArrayAllocDescriptorEx(vttypes[i].vt,1,&a);
357                 ok(a->fFeatures == vttypes[i].expflags,"SAADE(%d) resulted with flags %x, expected %x\n", vttypes[i].vt, a->fFeatures, vttypes[i].expflags);
358                 if (a->fFeatures & FADF_HAVEIID) {
359                         hres = pSafeArrayGetIID(a, &iid);
360                         ok(hres == S_OK,"SAGIID failed for vt %d with hres %lx", vttypes[i].vt,hres);
361                         switch (vttypes[i].vt) {
362                         case VT_UNKNOWN:
363                                 ok(IsEqualGUID(((GUID*)a)-1,&IID_IUnknown),"guid for VT_UNKNOWN is not IID_IUnknown");
364                                 ok(IsEqualGUID(&iid, &IID_IUnknown),"SAGIID returned wrong GUID for IUnknown");
365                                 break;
366                         case VT_DISPATCH:
367                                 ok(IsEqualGUID(((GUID*)a)-1,&IID_IDispatch),"guid for VT_UNKNOWN is not IID_IDispatch");
368                                 ok(IsEqualGUID(&iid, &IID_IDispatch),"SAGIID returned wrong GUID for IDispatch");
369                                 break;
370                         default:
371                                 ok(FALSE,"unknown vt %d with FADF_HAVEIID",vttypes[i].vt);
372                                 break;
373                         }
374                 } else {
375                         hres = pSafeArrayGetIID(a, &iid);
376                         ok(hres == E_INVALIDARG,"SAGIID did not fail for vt %d with hres %lx", vttypes[i].vt,hres);
377                 }
378                 if (a->fFeatures & FADF_RECORD) {
379                         ok(vttypes[i].vt == VT_RECORD,"FADF_RECORD for non record %d",vttypes[i].vt);
380                 }
381                 if (a->fFeatures & FADF_HAVEVARTYPE) {
382                         ok(vttypes[i].vt == ((DWORD*)a)[-1], "FADF_HAVEVARTYPE set, but vt %d mismatch stored %ld",vttypes[i].vt,((DWORD*)a)[-1]);
383                 }
384
385                 hres = pSafeArrayGetVartype(a, &vt);
386                 ok(hres == S_OK, "SAGVT of array with vt %d failed with %lx", vttypes[i].vt, hres);
387
388                 if (vttypes[i].vt == VT_DISPATCH) {
389                         /* Special case. Checked against Windows. */
390                         ok(vt == VT_UNKNOWN, "SAGVT of array with VT_DISPATCH returned not VT_UNKNOWN, but %d", vt);
391                 } else {
392                         ok(vt == vttypes[i].vt, "SAGVT of array with vt %d returned %d", vttypes[i].vt, vt);
393                 }
394
395                 if (a->fFeatures & FADF_HAVEIID) {
396                         hres = pSafeArraySetIID(a, &IID_IStorage); /* random IID */
397                         ok(hres == S_OK,"SASIID failed with FADF_HAVEIID set for vt %d with %lx", vttypes[i].vt, hres);
398                         hres = pSafeArrayGetIID(a, &iid);
399                         ok(hres == S_OK,"SAGIID failed with FADF_HAVEIID set for vt %d with %lx", vttypes[i].vt, hres);
400                         ok(IsEqualGUID(&iid, &IID_IStorage),"returned iid is not IID_IStorage");
401                 } else {
402                         hres = pSafeArraySetIID(a, &IID_IStorage); /* random IID */
403                         ok(hres == E_INVALIDARG,"SASIID did not failed with !FADF_HAVEIID set for vt %d with %lx", vttypes[i].vt, hres);
404                 }
405                 hres = SafeArrayDestroyDescriptor(a);
406                 ok(hres == S_OK,"SADD failed with hres %lx",hres);
407         }
408 }