ReactOS 0.4.16-dev-125-g798ea90
dictionary.c File Reference
#include <stdio.h>
#include "windows.h"
#include "ole2.h"
#include "oleauto.h"
#include "olectl.h"
#include "dispex.h"
#include "wine/test.h"
#include "scrrun.h"
Include dependency graph for dictionary.c:

Go to the source code of this file.

Classes

union  R4_FIELDS
 
union  R8_FIELDS
 

Macros

#define COBJMACROS
 
#define test_provideclassinfo(a, b)   _test_provideclassinfo((IDispatch*)a, b, __LINE__)
 

Functions

static void _test_provideclassinfo (IDispatch *disp, const GUID *guid, int line)
 
static void test_interfaces (void)
 
static void test_comparemode (void)
 
static DWORD get_str_hash (const WCHAR *str, CompareMethod method)
 
static DWORD get_num_hash (FLOAT num)
 
static DWORD get_ptr_hash (void *ptr)
 
static HRESULT WINAPI test_unk_QI (IUnknown *iface, REFIID riid, void **obj)
 
static HRESULT WINAPI test_unk_no_QI (IUnknown *iface, REFIID riid, void **obj)
 
static ULONG WINAPI test_unk_AddRef (IUnknown *iface)
 
static ULONG WINAPI test_unk_Release (IUnknown *iface)
 
static HRESULT WINAPI test_disp_QI (IDispatch *iface, REFIID riid, void **obj)
 
static ULONG WINAPI test_disp_AddRef (IDispatch *iface)
 
static ULONG WINAPI test_disp_Release (IDispatch *iface)
 
static HRESULT WINAPI test_disp_GetTypeInfoCount (IDispatch *iface, UINT *count)
 
static HRESULT WINAPI test_disp_GetTypeInfo (IDispatch *iface, UINT index, LCID lcid, ITypeInfo **ti)
 
static HRESULT WINAPI test_disp_GetIDsOfNames (IDispatch *iface, REFIID riid, LPOLESTR *names, UINT name_count, LCID lcid, DISPID *dispid)
 
static HRESULT WINAPI test_disp_Invoke (IDispatch *iface, DISPID dispid, REFIID riid, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *excepinfo, UINT *arg_err)
 
static void test_hash_value (void)
 
static void test_Exists (void)
 
static void test_Keys (void)
 
static void test_Remove (void)
 
static void test_Item (void)
 
static void test_Add (void)
 
static void test_IEnumVARIANT (void)
 
 START_TEST (dictionary)
 

Variables

static const IUnknownVtbl test_unk_vtbl
 
static const IUnknownVtbl test_unk_no_vtbl
 
static const IDispatchVtbl test_disp_vtbl
 
static IUnknown test_unk = { &test_unk_vtbl }
 
static IUnknown test_unk2 = { &test_unk_no_vtbl }
 
static IDispatch test_disp = { &test_disp_vtbl }
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 20 of file dictionary.c.

◆ test_provideclassinfo

#define test_provideclassinfo (   a,
  b 
)    _test_provideclassinfo((IDispatch*)a, b, __LINE__)

Definition at line 36 of file dictionary.c.

Function Documentation

◆ _test_provideclassinfo()

static void _test_provideclassinfo ( IDispatch disp,
const GUID guid,
int  line 
)
static

Definition at line 37 of file dictionary.c.

38{
40 TYPEATTR *attr;
41 ITypeInfo *ti;
42 IUnknown *unk;
43 HRESULT hr;
44
45 hr = IDispatch_QueryInterface(disp, &IID_IProvideClassInfo, (void **)&classinfo);
46 ok_(__FILE__,line) (hr == S_OK, "Failed to get IProvideClassInfo, %#x.\n", hr);
47
48 hr = IProvideClassInfo_GetClassInfo(classinfo, &ti);
49 ok_(__FILE__,line) (hr == S_OK, "GetClassInfo() failed, %#x.\n", hr);
50
51 hr = ITypeInfo_GetTypeAttr(ti, &attr);
52 ok_(__FILE__,line) (hr == S_OK, "GetTypeAttr() failed, %#x.\n", hr);
53
54 ok_(__FILE__,line) (IsEqualGUID(&attr->guid, guid), "Unexpected typeinfo %s, expected %s\n", wine_dbgstr_guid(&attr->guid),
56
57 hr = IProvideClassInfo_QueryInterface(classinfo, &IID_IUnknown, (void **)&unk);
58 ok(hr == S_OK, "Failed to QI for IUnknown.\n");
59 ok(unk == (IUnknown *)disp, "Got unk %p, original %p\n", unk, disp);
60 IUnknown_Release(unk);
61
62 IProvideClassInfo_Release(classinfo);
63 ITypeInfo_ReleaseTypeAttr(ti, attr);
64 ITypeInfo_Release(ti);
65}
#define ok(value,...)
Definition: atltest.h:57
#define ok_(x1, x2)
Definition: atltest.h:61
const GUID IID_IUnknown
classinfo
Definition: clsfactory.c:43
#define S_OK
Definition: intsafe.h:52
const GUID * guid
const GUID IID_IProvideClassInfo
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
HRESULT hr
Definition: shlfolder.c:183
Definition: cookie.c:202
Definition: parser.c:49

◆ get_num_hash()

static DWORD get_num_hash ( FLOAT  num)
static

Definition at line 195 of file dictionary.c.

196{
197 return (*((DWORD*)&num)) % 1201;
198}
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint num
Definition: glext.h:9618

◆ get_ptr_hash()

static DWORD get_ptr_hash ( void ptr)
static

Definition at line 200 of file dictionary.c.

201{
202 return PtrToUlong(ptr) % 1201;
203}
#define PtrToUlong(u)
Definition: config.h:107
static PVOID ptr
Definition: dispmode.c:27

◆ get_str_hash()

static DWORD get_str_hash ( const WCHAR str,
CompareMethod  method 
)
static

Definition at line 176 of file dictionary.c.

177{
178 DWORD hash = 0;
179
180 while (*str) {
181 WCHAR ch;
182
183 if (method == TextCompare || method == DatabaseCompare)
185 else
186 ch = *str;
187
188 hash += (hash << 4) + ch;
189 str++;
190 }
191
192 return hash % 1201;
193}
#define TextCompare
Definition: text.h:19
#define PtrToInt(p)
Definition: basetsd.h:86
#define IntToPtr(i)
Definition: basetsd.h:89
method
Definition: dragdrop.c:54
const WCHAR * str
Definition: _hash_fun.h:40
LPWSTR WINAPI CharLowerW(_Inout_ LPWSTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ START_TEST()

START_TEST ( dictionary  )

Definition at line 1076 of file dictionary.c.

1077{
1078 IDispatch *disp;
1079 HRESULT hr;
1080
1082
1083 hr = CoCreateInstance(&CLSID_Dictionary, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
1084 &IID_IDispatch, (void**)&disp);
1085 if(FAILED(hr)) {
1086 win_skip("Dictionary object is not supported: %08x\n", hr);
1088 return;
1089 }
1090 IDispatch_Release(disp);
1091
1095 test_Exists();
1096 test_Keys();
1097 test_Remove();
1098 test_Item();
1099 test_Add();
1101
1103}
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define FAILED(hr)
Definition: intsafe.h:51
static void test_hash_value(void)
Definition: dictionary.c:332
static void test_comparemode(void)
Definition: dictionary.c:129
static void test_Exists(void)
Definition: dictionary.c:766
static void test_interfaces(void)
Definition: dictionary.c:67
static void test_Remove(void)
Definition: dictionary.c:873
static void test_Keys(void)
Definition: dictionary.c:824
static void test_Item(void)
Definition: dictionary.c:902
static void test_Add(void)
Definition: dictionary.c:930
static void test_IEnumVARIANT(void)
Definition: dictionary.c:959
const GUID IID_IDispatch
#define win_skip
Definition: test.h:163

◆ test_Add()

static void test_Add ( void  )
static

Definition at line 930 of file dictionary.c.

931{
932 static const WCHAR testW[] = {'t','e','s','t','W',0};
934 IDictionary *dict;
935 HRESULT hr;
936 BSTR str;
937
938 hr = CoCreateInstance(&CLSID_Dictionary, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
939 &IID_IDictionary, (void**)&dict);
940 ok(hr == S_OK, "got 0x%08x\n", hr);
941
943 V_VT(&key) = VT_I2;
944 V_I2(&key) = 1;
946 V_BSTRREF(&item) = &str;
947 hr = IDictionary_Add(dict, &key, &item);
948 ok(hr == S_OK, "got 0x%08x\n", hr);
949
950 hr = IDictionary_get_Item(dict, &key, &item);
951 ok(hr == S_OK, "got 0x%08x\n", hr);
952 ok(V_VT(&item) == VT_BSTR, "got %d\n", V_VT(&item));
953
955
956 IDictionary_Release(dict);
957}
OLECHAR * BSTR
Definition: compat.h:2293
@ VT_BSTR
Definition: compat.h:2303
@ VT_BYREF
Definition: compat.h:2342
@ VT_I2
Definition: compat.h:2297
static const WCHAR testW[]
Definition: jsregexp.c:44
static ATOM item
Definition: dde.c:856
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
#define V_BSTRREF(A)
Definition: oleauto.h:227
#define V_VT(A)
Definition: oleauto.h:211
#define V_I2(A)
Definition: oleauto.h:245
Definition: copy.c:22

Referenced by START_TEST().

◆ test_comparemode()

static void test_comparemode ( void  )
static

Definition at line 129 of file dictionary.c.

130{
132 IDictionary *dict;
134 HRESULT hr;
135
136 hr = CoCreateInstance(&CLSID_Dictionary, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
137 &IID_IDictionary, (void**)&dict);
138 ok(hr == S_OK, "got 0x%08x\n", hr);
139
140 if (0) /* crashes on native */
141 hr = IDictionary_get_CompareMode(dict, NULL);
142
143 method = 10;
144 hr = IDictionary_get_CompareMode(dict, &method);
145 ok(hr == S_OK, "got 0x%08x\n", hr);
146 ok(method == BinaryCompare, "got %d\n", method);
147
148 /* invalid mode value is not checked */
149 hr = IDictionary_put_CompareMode(dict, 10);
150 ok(hr == S_OK, "got 0x%08x\n", hr);
151
152 hr = IDictionary_get_CompareMode(dict, &method);
153 ok(hr == S_OK, "got 0x%08x\n", hr);
154 ok(method == 10, "got %d\n", method);
155
156 hr = IDictionary_put_CompareMode(dict, DatabaseCompare);
157 ok(hr == S_OK, "got 0x%08x\n", hr);
158
159 hr = IDictionary_get_CompareMode(dict, &method);
160 ok(hr == S_OK, "got 0x%08x\n", hr);
161 ok(method == DatabaseCompare, "got %d\n", method);
162
163 /* try to change mode of a non-empty dict */
164 V_VT(&key) = VT_I2;
165 V_I2(&key) = 0;
167 hr = IDictionary_Add(dict, &key, &item);
168 ok(hr == S_OK, "got 0x%08x\n", hr);
169
170 hr = IDictionary_put_CompareMode(dict, BinaryCompare);
171 ok(hr == CTL_E_ILLEGALFUNCTIONCALL, "got 0x%08x\n", hr);
172
173 IDictionary_Release(dict);
174}
CompareMethod
Definition: scrrun.idl:46
#define CTL_E_ILLEGALFUNCTIONCALL
Definition: olectl.h:267
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568

Referenced by START_TEST().

◆ test_disp_AddRef()

static ULONG WINAPI test_disp_AddRef ( IDispatch iface)
static

Definition at line 281 of file dictionary.c.

282{
283 ok(0, "unexpected\n");
284 return 2;
285}

◆ test_disp_GetIDsOfNames()

static HRESULT WINAPI test_disp_GetIDsOfNames ( IDispatch iface,
REFIID  riid,
LPOLESTR names,
UINT  name_count,
LCID  lcid,
DISPID dispid 
)
static

Definition at line 304 of file dictionary.c.

306{
307 ok(0, "unexpected call\n");
308 return E_NOTIMPL;
309}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ test_disp_GetTypeInfo()

static HRESULT WINAPI test_disp_GetTypeInfo ( IDispatch iface,
UINT  index,
LCID  lcid,
ITypeInfo **  ti 
)
static

Definition at line 298 of file dictionary.c.

299{
300 ok(0, "unexpected call\n");
301 return E_NOTIMPL;
302}

◆ test_disp_GetTypeInfoCount()

static HRESULT WINAPI test_disp_GetTypeInfoCount ( IDispatch iface,
UINT count 
)
static

Definition at line 292 of file dictionary.c.

293{
294 ok(0, "unexpected call\n");
295 return E_NOTIMPL;
296}

◆ test_disp_Invoke()

static HRESULT WINAPI test_disp_Invoke ( IDispatch iface,
DISPID  dispid,
REFIID  riid,
LCID  lcid,
WORD  flags,
DISPPARAMS *  params,
VARIANT result,
EXCEPINFO *  excepinfo,
UINT arg_err 
)
static

Definition at line 311 of file dictionary.c.

313{
314 ok(0, "unexpected call\n");
315 return E_NOTIMPL;
316}

◆ test_disp_QI()

static HRESULT WINAPI test_disp_QI ( IDispatch iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 269 of file dictionary.c.

270{
272 *obj = iface;
273 return S_OK;
274 }
275
276 ok(0, "unexpected %s\n", wine_dbgstr_guid(riid));
277 *obj = NULL;
278 return E_NOINTERFACE;
279}
REFIID riid
Definition: atlbase.h:39
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ test_disp_Release()

static ULONG WINAPI test_disp_Release ( IDispatch iface)
static

Definition at line 287 of file dictionary.c.

288{
289 return 1;
290}

◆ test_Exists()

static void test_Exists ( void  )
static

Definition at line 766 of file dictionary.c.

767{
768 VARIANT_BOOL exists;
769 IDictionary *dict;
771 HRESULT hr;
772
773 hr = CoCreateInstance(&CLSID_Dictionary, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
774 &IID_IDictionary, (void**)&dict);
775 ok(hr == S_OK, "got 0x%08x\n", hr);
776
777if (0) /* crashes on native */
778 hr = IDictionary_Exists(dict, NULL, NULL);
779
780 V_VT(&key) = VT_I2;
781 V_I2(&key) = 0;
782 hr = IDictionary_Exists(dict, &key, NULL);
783 ok(hr == CTL_E_ILLEGALFUNCTIONCALL, "got 0x%08x\n", hr);
784
785 V_VT(&key) = VT_I2;
786 V_I2(&key) = 0;
787 exists = VARIANT_TRUE;
788 hr = IDictionary_Exists(dict, &key, &exists);
789 ok(hr == S_OK, "got 0x%08x\n", hr);
790 ok(exists == VARIANT_FALSE, "got %x\n", exists);
791
793 hr = IDictionary_Add(dict, &key, &item);
794 ok(hr == S_OK, "got 0x%08x\n", hr);
795
796 V_VT(&key) = VT_R4;
797 V_R4(&key) = 0.0;
798 hr = IDictionary_Add(dict, &key, &item);
799 ok(hr == CTL_E_KEY_ALREADY_EXISTS, "got 0x%08x\n", hr);
800
801 V_VT(&key) = VT_I2;
802 V_I2(&key) = 0;
803 hr = IDictionary_Exists(dict, &key, NULL);
804 ok(hr == CTL_E_ILLEGALFUNCTIONCALL, "got 0x%08x\n", hr);
805
806 V_VT(&key) = VT_I2;
807 V_I2(&key) = 0;
808 exists = VARIANT_FALSE;
809 hr = IDictionary_Exists(dict, &key, &exists);
810 ok(hr == S_OK, "got 0x%08x\n", hr);
811 ok(exists == VARIANT_TRUE, "got %x\n", exists);
812
813 /* key of different type, but resolves to same hash value */
814 V_VT(&key) = VT_R4;
815 V_R4(&key) = 0.0;
816 exists = VARIANT_FALSE;
817 hr = IDictionary_Exists(dict, &key, &exists);
818 ok(hr == S_OK, "got 0x%08x\n", hr);
819 ok(exists == VARIANT_TRUE, "got %x\n", exists);
820
821 IDictionary_Release(dict);
822}
short VARIANT_BOOL
Definition: compat.h:2290
@ VT_R4
Definition: compat.h:2299
#define V_R4(A)
Definition: oleauto.h:260

Referenced by START_TEST().

◆ test_hash_value()

static void test_hash_value ( void  )
static

Definition at line 332 of file dictionary.c.

333{
334 /* string test data */
335 static const WCHAR str_hash_tests[][10] = {
336 {'a','b','c','d',0},
337 {'a','B','C','d','1',0},
338 {'1','2','3',0},
339 {'A',0},
340 {'a',0},
341 { 0 }
342 };
343
344 static const int int_hash_tests[] = {
345 0, -1, 100, 1, 255
346 };
347
348 static const FLOAT float_hash_tests[] = {
349 0.0, -1.0, 100.0, 1.0, 255.0, 1.234
350 };
351
352 IDictionary *dict;
354 IDispatch *disp;
356 IUnknown *unk;
357 R8_FIELDS fx8;
358 R4_FIELDS fx4;
359 HRESULT hr;
360 unsigned i;
361
362 hr = CoCreateInstance(&CLSID_Dictionary, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
363 &IID_IDictionary, (void**)&dict);
364 ok(hr == S_OK, "got 0x%08x\n", hr);
365
366 V_VT(&key) = VT_BSTR;
367 V_BSTR(&key) = NULL;
369 hr = IDictionary_get_HashVal(dict, &key, &hash);
370 ok(hr == S_OK, "got 0x%08x\n", hr);
371 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
372 ok(V_I4(&hash) == 0, "got %d\n", V_I4(&hash));
373
374 for (i = 0; i < ARRAY_SIZE(str_hash_tests); i++) {
375 expected = get_str_hash(str_hash_tests[i], BinaryCompare);
376
377 hr = IDictionary_put_CompareMode(dict, BinaryCompare);
378 ok(hr == S_OK, "got 0x%08x\n", hr);
379
380 V_VT(&key) = VT_BSTR;
381 V_BSTR(&key) = SysAllocString(str_hash_tests[i]);
383 hr = IDictionary_get_HashVal(dict, &key, &hash);
384 ok(hr == S_OK, "got 0x%08x\n", hr);
385 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
386 ok(V_I4(&hash) == expected, "%d: binary mode: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash),
387 expected);
389
390 expected = get_str_hash(str_hash_tests[i], TextCompare);
391 hr = IDictionary_put_CompareMode(dict, TextCompare);
392 ok(hr == S_OK, "got 0x%08x\n", hr);
393
394 V_VT(&key) = VT_BSTR;
395 V_BSTR(&key) = SysAllocString(str_hash_tests[i]);
397 hr = IDictionary_get_HashVal(dict, &key, &hash);
398 ok(hr == S_OK, "got 0x%08x\n", hr);
399 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
400 ok(V_I4(&hash) == expected, "%d: text mode: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash),
401 expected);
403
404 expected = get_str_hash(str_hash_tests[i], DatabaseCompare);
405 hr = IDictionary_put_CompareMode(dict, DatabaseCompare);
406 ok(hr == S_OK, "got 0x%08x\n", hr);
407
408 V_VT(&key) = VT_BSTR;
409 V_BSTR(&key) = SysAllocString(str_hash_tests[i]);
411 hr = IDictionary_get_HashVal(dict, &key, &hash);
412 ok(hr == S_OK, "got 0x%08x\n", hr);
413 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
414 ok(V_I4(&hash) == expected, "%d: db mode: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash),
415 expected);
417 }
418
419 V_VT(&key) = VT_INT;
420 V_INT(&key) = 1;
422 hr = IDictionary_get_HashVal(dict, &key, &hash);
423 ok(hr == CTL_E_ILLEGALFUNCTIONCALL || broken(hr == S_OK) /* win2k, win2k3 */, "got 0x%08x\n", hr);
424 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
425 ok(V_I4(&hash) == ~0u, "got hash 0x%08x\n", V_I4(&hash));
426
427 V_VT(&key) = VT_UINT;
428 V_UINT(&key) = 1;
430 hr = IDictionary_get_HashVal(dict, &key, &hash);
431 ok(hr == CTL_E_ILLEGALFUNCTIONCALL || broken(hr == S_OK) /* win2k, win2k3 */, "got 0x%08x\n", hr);
432 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
433 ok(V_I4(&hash) == ~0u, "got hash 0x%08x\n", V_I4(&hash));
434
435 V_VT(&key) = VT_I1;
436 V_I1(&key) = 1;
438 hr = IDictionary_get_HashVal(dict, &key, &hash);
439 ok(hr == CTL_E_ILLEGALFUNCTIONCALL || broken(hr == S_OK) /* win2k, win2k3 */, "got 0x%08x\n", hr);
440 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
441 ok(V_I4(&hash) == ~0u || broken(V_I4(&hash) == 0xa1), "got hash 0x%08x\n", V_I4(&hash));
442
443 V_VT(&key) = VT_I8;
444 V_I8(&key) = 1;
446 hr = IDictionary_get_HashVal(dict, &key, &hash);
447 ok(hr == CTL_E_ILLEGALFUNCTIONCALL || broken(hr == S_OK) /* win2k, win2k3 */, "got 0x%08x\n", hr);
448 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
449 ok(V_I4(&hash) == ~0u, "got hash 0x%08x\n", V_I4(&hash));
450
451 V_VT(&key) = VT_UI2;
452 V_UI2(&key) = 1;
454 hr = IDictionary_get_HashVal(dict, &key, &hash);
455 ok(hr == CTL_E_ILLEGALFUNCTIONCALL || broken(hr == S_OK) /* win2k, win2k3 */, "got 0x%08x\n", hr);
456 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
457 ok(V_I4(&hash) == ~0u, "got hash 0x%08x\n", V_I4(&hash));
458
459 V_VT(&key) = VT_UI4;
460 V_UI4(&key) = 1;
462 hr = IDictionary_get_HashVal(dict, &key, &hash);
463 ok(hr == CTL_E_ILLEGALFUNCTIONCALL || broken(hr == S_OK) /* win2k, win2k3 */, "got 0x%08x\n", hr);
464 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
465 ok(V_I4(&hash) == ~0u, "got hash 0x%08x\n", V_I4(&hash));
466
467 for (i = 0; i < ARRAY_SIZE(int_hash_tests); i++) {
468 SHORT i2;
469 BYTE ui1;
470 LONG i4;
471
472 expected = get_num_hash(int_hash_tests[i]);
473
474 V_VT(&key) = VT_I2;
475 V_I2(&key) = int_hash_tests[i];
477 hr = IDictionary_get_HashVal(dict, &key, &hash);
478 ok(hr == S_OK, "got 0x%08x\n", hr);
479 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
480 ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash),
481 expected);
482
483 i2 = int_hash_tests[i];
485 V_I2REF(&key) = &i2;
487 hr = IDictionary_get_HashVal(dict, &key, &hash);
488 ok(hr == S_OK, "got 0x%08x\n", hr);
489 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
490 ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash),
491 expected);
492
493 V_VT(&key) = VT_I4;
494 V_I4(&key) = int_hash_tests[i];
496 hr = IDictionary_get_HashVal(dict, &key, &hash);
497 ok(hr == S_OK, "got 0x%08x\n", hr);
498 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
499 ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash),
500 expected);
501
502 i4 = int_hash_tests[i];
504 V_I4REF(&key) = &i4;
506 hr = IDictionary_get_HashVal(dict, &key, &hash);
507 ok(hr == S_OK, "got 0x%08x\n", hr);
508 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
509 ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash),
510 expected);
511
512 expected = get_num_hash((FLOAT)(BYTE)int_hash_tests[i]);
513 V_VT(&key) = VT_UI1;
514 V_UI1(&key) = int_hash_tests[i];
516 hr = IDictionary_get_HashVal(dict, &key, &hash);
517 ok(hr == S_OK, "got 0x%08x\n", hr);
518 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
519 ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash),
520 expected);
521
522 ui1 = int_hash_tests[i];
524 V_UI1REF(&key) = &ui1;
526 hr = IDictionary_get_HashVal(dict, &key, &hash);
527 ok(hr == S_OK, "got 0x%08x\n", hr);
528 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
529 ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash),
530 expected);
531 }
532
533 /* nan */
534 fx4.f = 10.0;
535 fx4.i.exp_bias = 0xff;
536
537 V_VT(&key) = VT_R4;
538 V_R4(&key) = fx4.f;
540 hr = IDictionary_get_HashVal(dict, &key, &hash);
541 ok(hr == CTL_E_ILLEGALFUNCTIONCALL || broken(hr == S_OK) /* win2k, win2k3 */, "got 0x%08x\n", hr);
542 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
543 ok(V_I4(&hash) == ~0u || broken(V_I4(&hash) == 0 /* win2k */ ||
544 V_I4(&hash) == 0x1f4 /* vista, win2k8 */), "got hash 0x%08x\n", V_I4(&hash));
545
546 /* inf */
547 fx4.f = 10.0;
548 fx4.i.m = 0;
549 fx4.i.exp_bias = 0xff;
550
551 V_VT(&key) = VT_R4;
552 V_R4(&key) = fx4.f;
553 V_I4(&hash) = 10;
554 hr = IDictionary_get_HashVal(dict, &key, &hash);
555 ok(hr == S_OK, "got 0x%08x\n", hr);
556 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
557 ok(V_I4(&hash) == 0, "got hash 0x%08x\n", V_I4(&hash));
558
559 /* nan */
560 fx8.d = 10.0;
561 fx8.i.exp_bias = 0x7ff;
562
563 V_VT(&key) = VT_R8;
564 V_R8(&key) = fx8.d;
566 hr = IDictionary_get_HashVal(dict, &key, &hash);
567 ok(hr == CTL_E_ILLEGALFUNCTIONCALL || broken(hr == S_OK) /* win2k, win2k3 */, "got 0x%08x\n", hr);
568 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
569 ok(V_I4(&hash) == ~0u || broken(V_I4(&hash) == 0 /* win2k */ ||
570 V_I4(&hash) == 0x1f4 /* vista, win2k8 */), "got hash 0x%08x\n", V_I4(&hash));
571
572 V_VT(&key) = VT_DATE;
573 V_DATE(&key) = fx8.d;
575 hr = IDictionary_get_HashVal(dict, &key, &hash);
576 ok(hr == CTL_E_ILLEGALFUNCTIONCALL || broken(hr == S_OK) /* win2k, win2k3 */, "got 0x%08x\n", hr);
577 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
578 ok(V_I4(&hash) == ~0u || broken(V_I4(&hash) == 0 /* win2k */ ||
579 V_I4(&hash) == 0x1f4 /* vista, win2k8 */), "got hash 0x%08x\n", V_I4(&hash));
580
581 /* inf */
582 fx8.d = 10.0;
583 fx8.i.m_lo = 0;
584 fx8.i.m_hi = 0;
585 fx8.i.exp_bias = 0x7ff;
586
587 V_VT(&key) = VT_R8;
588 V_R8(&key) = fx8.d;
589 V_I4(&hash) = 10;
590 hr = IDictionary_get_HashVal(dict, &key, &hash);
591 ok(hr == S_OK, "got 0x%08x\n", hr);
592 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
593 ok(V_I4(&hash) == 0, "got hash 0x%08x\n", V_I4(&hash));
594
595 V_VT(&key) = VT_DATE;
596 V_DATE(&key) = fx8.d;
597 V_I4(&hash) = 10;
598 hr = IDictionary_get_HashVal(dict, &key, &hash);
599 ok(hr == S_OK, "got 0x%08x\n", hr);
600 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
601 ok(V_I4(&hash) == 0, "got hash 0x%08x\n", V_I4(&hash));
602
603 for (i = 0; i < ARRAY_SIZE(float_hash_tests); i++) {
604 double dbl;
605 FLOAT flt;
606 DATE date;
607
608 expected = get_num_hash(float_hash_tests[i]);
609
610 V_VT(&key) = VT_R4;
611 V_R4(&key) = float_hash_tests[i];
613 hr = IDictionary_get_HashVal(dict, &key, &hash);
614 ok(hr == S_OK, "got 0x%08x\n", hr);
615 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
616 ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash),
617 expected);
618
619 flt = float_hash_tests[i];
621 V_R4REF(&key) = &flt;
623 hr = IDictionary_get_HashVal(dict, &key, &hash);
624 ok(hr == S_OK, "got 0x%08x\n", hr);
625 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
626 ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash),
627 expected);
628
629 V_VT(&key) = VT_R8;
630 V_R8(&key) = float_hash_tests[i];
632 hr = IDictionary_get_HashVal(dict, &key, &hash);
633 ok(hr == S_OK, "got 0x%08x\n", hr);
634 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
635 ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash),
636 expected);
637
638 dbl = float_hash_tests[i];
640 V_R8REF(&key) = &dbl;
642 hr = IDictionary_get_HashVal(dict, &key, &hash);
643 ok(hr == S_OK, "got 0x%08x\n", hr);
644 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
645 ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash),
646 expected);
647
648 V_VT(&key) = VT_DATE;
649 V_DATE(&key) = float_hash_tests[i];
651 hr = IDictionary_get_HashVal(dict, &key, &hash);
652 ok(hr == S_OK, "got 0x%08x\n", hr);
653 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
654 ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash),
655 expected);
656
658 date = float_hash_tests[i];
659 V_DATEREF(&key) = &date;
661 hr = IDictionary_get_HashVal(dict, &key, &hash);
662 ok(hr == S_OK, "got 0x%08x\n", hr);
663 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
664 ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash),
665 expected);
666 }
667
668 /* interface pointers as keys */
669 V_VT(&key) = VT_UNKNOWN;
670 V_UNKNOWN(&key) = 0;
672 V_I4(&hash) = 1;
673 hr = IDictionary_get_HashVal(dict, &key, &hash);
674 ok(hr == S_OK, "got 0x%08x\n", hr);
675 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
676 ok(V_I4(&hash) == 0, "got hash 0x%08x, expected 0\n", V_I4(&hash));
677
678 /* QI doesn't work */
679 V_VT(&key) = VT_UNKNOWN;
683 hr = IDictionary_get_HashVal(dict, &key, &hash);
684 ok(hr == CTL_E_ILLEGALFUNCTIONCALL || broken(hr == S_OK) /* win2k */, "got 0x%08x\n", hr);
685 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
686 ok(V_I4(&hash) == ~0u, "got hash 0x%08x, expected 0x%08x\n", V_I4(&hash), expected);
687
688 V_VT(&key) = VT_UNKNOWN;
692 hr = IDictionary_get_HashVal(dict, &key, &hash);
693 ok(hr == S_OK, "got 0x%08x\n", hr);
694 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
695 ok(V_I4(&hash) == expected, "got hash 0x%08x, expected 0x%08x\n", V_I4(&hash), expected);
696
697 /* interface without IDispatch support */
698 V_VT(&key) = VT_DISPATCH;
702 hr = IDictionary_get_HashVal(dict, &key, &hash);
703 ok(hr == S_OK, "got 0x%08x\n", hr);
704 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
705 ok(V_I4(&hash) == expected, "got hash 0x%08x, expected 0x%08x\n", V_I4(&hash), expected);
706
707 V_VT(&key) = VT_DISPATCH;
711 hr = IDictionary_get_HashVal(dict, &key, &hash);
712 ok(hr == S_OK, "got 0x%08x\n", hr);
713 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
714 ok(V_I4(&hash) == expected, "got hash 0x%08x, expected 0x%08x\n", V_I4(&hash), expected);
715
716 /* same with BYREF */
717if (0) { /* crashes on native */
719 V_UNKNOWNREF(&key) = 0;
720 hr = IDictionary_get_HashVal(dict, &key, &hash);
721}
722 unk = NULL;
724 V_UNKNOWNREF(&key) = &unk;
726 V_I4(&hash) = 1;
727 hr = IDictionary_get_HashVal(dict, &key, &hash);
728 ok(hr == S_OK, "got 0x%08x\n", hr);
729 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
730 ok(V_I4(&hash) == 0, "got hash 0x%08x, expected 0\n", V_I4(&hash));
731
733 unk = &test_unk;
734 V_UNKNOWNREF(&key) = &unk;
737 hr = IDictionary_get_HashVal(dict, &key, &hash);
738 ok(hr == S_OK, "got 0x%08x\n", hr);
739 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
740 ok(V_I4(&hash) == expected, "got hash 0x%08x, expected 0x%08x\n", V_I4(&hash), expected);
741
742 /* interface without IDispatch support */
744 unk = &test_unk;
745 V_DISPATCHREF(&key) = (IDispatch**)&unk;
748 hr = IDictionary_get_HashVal(dict, &key, &hash);
749 ok(hr == S_OK, "got 0x%08x\n", hr);
750 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
751 ok(V_I4(&hash) == expected, "got hash 0x%08x, expected 0x%08x\n", V_I4(&hash), expected);
752
754 disp = &test_disp;
755 V_DISPATCHREF(&key) = &disp;
758 hr = IDictionary_get_HashVal(dict, &key, &hash);
759 ok(hr == S_OK, "got 0x%08x\n", hr);
760 ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash));
761 ok(V_I4(&hash) == expected, "got hash 0x%08x, expected 0x%08x\n", V_I4(&hash), expected);
762
763 IDictionary_Release(dict);
764}
#define broken(x)
Definition: atltest.h:178
#define ARRAY_SIZE(A)
Definition: main.h:20
double DATE
Definition: compat.h:2253
@ VT_INT
Definition: compat.h:2316
@ VT_UNKNOWN
Definition: compat.h:2308
@ VT_UI2
Definition: compat.h:2312
@ VT_R8
Definition: compat.h:2300
@ VT_I8
Definition: compat.h:2314
@ VT_I1
Definition: compat.h:2310
@ VT_I4
Definition: compat.h:2298
@ VT_DATE
Definition: compat.h:2302
@ VT_UI4
Definition: compat.h:2313
@ VT_UINT
Definition: compat.h:2317
@ VT_DISPATCH
Definition: compat.h:2304
@ VT_UI1
Definition: compat.h:2311
static DWORD get_str_hash(const WCHAR *str, CompareMethod method)
Definition: dictionary.c:750
static DWORD get_num_hash(FLOAT num)
Definition: dictionary.c:768
static DWORD get_ptr_hash(void *ptr)
Definition: dictionary.c:789
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
__u16 date
Definition: mkdosfs.c:8
BOOL expected
Definition: store.c:2063
static IUnknown test_unk2
Definition: dictionary.c:329
static IDispatch test_disp
Definition: dictionary.c:330
static IUnknown test_unk
Definition: dictionary.c:328
#define V_UI1(A)
Definition: oleauto.h:266
#define V_I8(A)
Definition: oleauto.h:249
#define V_R4REF(A)
Definition: oleauto.h:261
#define V_UNKNOWN(A)
Definition: oleauto.h:281
#define V_UNKNOWNREF(A)
Definition: oleauto.h:282
#define V_UI2(A)
Definition: oleauto.h:268
#define V_I1(A)
Definition: oleauto.h:243
#define V_DISPATCHREF(A)
Definition: oleauto.h:240
#define V_BSTR(A)
Definition: oleauto.h:226
#define V_DATEREF(A)
Definition: oleauto.h:232
#define V_I4(A)
Definition: oleauto.h:247
#define V_UINT(A)
Definition: oleauto.h:264
#define V_UI4(A)
Definition: oleauto.h:270
#define V_DISPATCH(A)
Definition: oleauto.h:239
#define V_R8(A)
Definition: oleauto.h:262
#define V_I2REF(A)
Definition: oleauto.h:246
#define V_DATE(A)
Definition: oleauto.h:231
#define V_UI1REF(A)
Definition: oleauto.h:267
#define V_R8REF(A)
Definition: oleauto.h:263
#define V_I4REF(A)
Definition: oleauto.h:248
short SHORT
Definition: pedump.c:59
long LONG
Definition: pedump.c:60
float FLOAT
Definition: typedefs.h:69
struct R4_FIELDS::@527 i
float f
Definition: vartype.c:5419
double d
Definition: vartype.c:5479
struct R8_FIELDS::@528 i
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
#define V_INT(x)
Definition: webchild.h:78
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_IEnumVARIANT()

static void test_IEnumVARIANT ( void  )
static

Definition at line 959 of file dictionary.c.

960{
961 IUnknown *enum1, *enum2;
964 IDictionary *dict;
965 ULONG fetched;
966 HRESULT hr;
967
968 hr = CoCreateInstance(&CLSID_Dictionary, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
969 &IID_IDictionary, (void**)&dict);
970 ok(hr == S_OK, "got 0x%08x\n", hr);
971
972 if (0) /* crashes on native */
973 hr = IDictionary__NewEnum(dict, NULL);
974
975 hr = IDictionary__NewEnum(dict, &enum1);
976 ok(hr == S_OK, "got 0x%08x\n", hr);
977
978 hr = IDictionary__NewEnum(dict, &enum2);
979 ok(hr == S_OK, "got 0x%08x\n", hr);
980 ok(enum1 != enum2, "got %p, %p\n", enum2, enum1);
981 IUnknown_Release(enum2);
982
983 hr = IUnknown_QueryInterface(enum1, &IID_IEnumVARIANT, (void**)&enumvar);
984 ok(hr == S_OK, "got 0x%08x\n", hr);
985 IUnknown_Release(enum1);
986
987 /* dictionary is empty */
988 hr = IEnumVARIANT_Skip(enumvar, 1);
989 ok(hr == S_FALSE, "got 0x%08x\n", hr);
990
991 hr = IEnumVARIANT_Skip(enumvar, 0);
992 ok(hr == S_OK, "got 0x%08x\n", hr);
993
994 V_VT(&key) = VT_I2;
995 V_I2(&key) = 1;
996 V_VT(&item) = VT_I4;
997 V_I4(&item) = 100;
998 hr = IDictionary_Add(dict, &key, &item);
999 ok(hr == S_OK, "got 0x%08x\n", hr);
1000
1001 hr = IEnumVARIANT_Skip(enumvar, 0);
1002 ok(hr == S_OK, "got 0x%08x\n", hr);
1003
1004 hr = IEnumVARIANT_Reset(enumvar);
1005 ok(hr == S_OK, "got 0x%08x\n", hr);
1006 hr = IEnumVARIANT_Skip(enumvar, 1);
1007 ok(hr == S_OK, "got 0x%08x\n", hr);
1008 hr = IEnumVARIANT_Skip(enumvar, 1);
1009 ok(hr == S_FALSE, "got 0x%08x\n", hr);
1010
1011 V_VT(&key) = VT_I2;
1012 V_I2(&key) = 4000;
1013 V_VT(&item) = VT_I4;
1014 V_I4(&item) = 200;
1015 hr = IDictionary_Add(dict, &key, &item);
1016 ok(hr == S_OK, "got 0x%08x\n", hr);
1017
1018 V_VT(&key) = VT_I2;
1019 V_I2(&key) = 0;
1020 V_VT(&item) = VT_I4;
1021 V_I4(&item) = 300;
1022 hr = IDictionary_Add(dict, &key, &item);
1023 ok(hr == S_OK, "got 0x%08x\n", hr);
1024
1025 hr = IEnumVARIANT_Reset(enumvar);
1026 ok(hr == S_OK, "got 0x%08x\n", hr);
1027
1028 VariantInit(&key);
1029 hr = IEnumVARIANT_Next(enumvar, 1, &key, &fetched);
1030 ok(hr == S_OK, "got 0x%08x\n", hr);
1031 ok(V_VT(&key) == VT_I2, "got %d\n", V_VT(&key));
1032 ok(V_I2(&key) == 1, "got %d\n", V_I2(&key));
1033 ok(fetched == 1, "got %u\n", fetched);
1034
1035 hr = IEnumVARIANT_Reset(enumvar);
1036 ok(hr == S_OK, "got 0x%08x\n", hr);
1037
1038 hr = IDictionary_Remove(dict, &key);
1039 ok(hr == S_OK, "got 0x%08x\n", hr);
1040
1041 VariantInit(&key);
1042 hr = IEnumVARIANT_Next(enumvar, 1, &key, &fetched);
1043 ok(hr == S_OK, "got 0x%08x\n", hr);
1044 ok(V_VT(&key) == VT_I2, "got %d\n", V_VT(&key));
1045 ok(V_I2(&key) == 4000, "got %d\n", V_I2(&key));
1046 ok(fetched == 1, "got %u\n", fetched);
1047
1048 VariantInit(&key);
1049 hr = IEnumVARIANT_Next(enumvar, 1, &key, &fetched);
1050 ok(hr == S_OK, "got 0x%08x\n", hr);
1051 ok(V_VT(&key) == VT_I2, "got %d\n", V_VT(&key));
1052 ok(V_I2(&key) == 0, "got %d\n", V_I2(&key));
1053 ok(fetched == 1, "got %u\n", fetched);
1054
1055 /* enumeration reached the bottom, add one more pair */
1056 VariantInit(&key);
1057 hr = IEnumVARIANT_Next(enumvar, 1, &key, &fetched);
1058 ok(hr == S_FALSE, "got 0x%08x\n", hr);
1059
1060 V_VT(&key) = VT_I2;
1061 V_I2(&key) = 13;
1062 V_VT(&item) = VT_I4;
1063 V_I4(&item) = 350;
1064 hr = IDictionary_Add(dict, &key, &item);
1065 ok(hr == S_OK, "got 0x%08x\n", hr);
1066
1067 /* still doesn't work until Reset() */
1068 VariantInit(&key);
1069 hr = IEnumVARIANT_Next(enumvar, 1, &key, &fetched);
1070 ok(hr == S_FALSE, "got 0x%08x\n", hr);
1071
1072 IEnumVARIANT_Release(enumvar);
1073 IDictionary_Release(dict);
1074}
uint32_t ULONG
Definition: typedefs.h:59
#define S_FALSE
Definition: winerror.h:2357

Referenced by START_TEST().

◆ test_interfaces()

static void test_interfaces ( void  )
static

Definition at line 67 of file dictionary.c.

68{
69 static const WCHAR key_add[] = {'a', 0};
70 static const WCHAR key_add_value[] = {'a', 0};
71 static const WCHAR key_non_exist[] = {'b', 0};
72 HRESULT hr;
73 IDispatch *disp;
74 IDispatchEx *dispex;
75 IDictionary *dict;
78 VARIANT_BOOL exists;
79 LONG count = 0;
80
81 hr = CoCreateInstance(&CLSID_Dictionary, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
82 &IID_IDispatch, (void**)&disp);
83 ok(hr == S_OK, "got 0x%08x\n", hr);
84
87
88 hr = IDispatch_QueryInterface(disp, &IID_IDictionary, (void**)&dict);
89 ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
90
91 hr = IDispatch_QueryInterface(disp, &IID_IObjectWithSite, (void**)&site);
92 ok(hr == E_NOINTERFACE, "got 0x%08x, expected 0x%08x\n", hr, E_NOINTERFACE);
93
94 hr = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
95 ok(hr == E_NOINTERFACE, "got 0x%08x, expected 0x%08x\n", hr, E_NOINTERFACE);
96
97 test_provideclassinfo(disp, &CLSID_Dictionary);
98
99 V_VT(&key) = VT_BSTR;
100 V_BSTR(&key) = SysAllocString(key_add);
101 V_VT(&value) = VT_BSTR;
102 V_BSTR(&value) = SysAllocString(key_add_value);
103 hr = IDictionary_Add(dict, &key, &value);
104 ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
106
107 exists = VARIANT_FALSE;
108 hr = IDictionary_Exists(dict, &key, &exists);
109 ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
110 ok(exists == VARIANT_TRUE, "Expected TRUE but got FALSE.\n");
112
113 exists = VARIANT_TRUE;
114 V_VT(&key) = VT_BSTR;
115 V_BSTR(&key) = SysAllocString(key_non_exist);
116 hr = IDictionary_Exists(dict, &key, &exists);
117 ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
118 ok(exists == VARIANT_FALSE, "Expected FALSE but got TRUE.\n");
120
121 hr = IDictionary_get_Count(dict, &count);
122 ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
123 ok(count == 1, "got %d, expected 1\n", count);
124
125 IDictionary_Release(dict);
126 IDispatch_Release(disp);
127}
GLuint GLuint GLsizei count
Definition: gl.h:1545
const IID IID_IObjectWithSite
static IActiveScriptSite * site
Definition: script.c:149
#define test_provideclassinfo(a, b)
Definition: dictionary.c:36
Definition: pdh_main.c:94

Referenced by START_TEST().

◆ test_Item()

static void test_Item ( void  )
static

Definition at line 902 of file dictionary.c.

903{
905 IDictionary *dict;
906 HRESULT hr;
907
908 hr = CoCreateInstance(&CLSID_Dictionary, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
909 &IID_IDictionary, (void**)&dict);
910 ok(hr == S_OK, "got 0x%08x\n", hr);
911
912 V_VT(&key) = VT_I2;
913 V_I2(&key) = 10;
914 V_VT(&item) = VT_I2;
915 V_I2(&item) = 123;
916 hr = IDictionary_get_Item(dict, &key, &item);
917 ok(hr == S_OK, "got 0x%08x\n", hr);
918 ok(V_VT(&item) == VT_EMPTY, "got %d\n", V_VT(&item));
919
920 V_VT(&key) = VT_I2;
921 V_I2(&key) = 10;
922 V_VT(&item) = VT_I2;
923 hr = IDictionary_get_Item(dict, &key, &item);
924 ok(hr == S_OK, "got 0x%08x\n", hr);
925 ok(V_VT(&item) == VT_EMPTY, "got %d\n", V_VT(&item));
926
927 IDictionary_Release(dict);
928}
@ VT_EMPTY
Definition: compat.h:2295

Referenced by START_TEST().

◆ test_Keys()

static void test_Keys ( void  )
static

Definition at line 824 of file dictionary.c.

825{
826 VARIANT key, keys, item;
827 IDictionary *dict;
828 LONG index;
829 HRESULT hr;
830
831 hr = CoCreateInstance(&CLSID_Dictionary, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
832 &IID_IDictionary, (void**)&dict);
833 ok(hr == S_OK, "got 0x%08x\n", hr);
834
835 hr = IDictionary_Keys(dict, NULL);
836 ok(hr == S_OK, "got 0x%08x\n", hr);
837
838 VariantInit(&keys);
839 hr = IDictionary_Keys(dict, &keys);
840 ok(hr == S_OK, "got 0x%08x\n", hr);
841 ok(V_VT(&keys) == (VT_ARRAY|VT_VARIANT), "got %d\n", V_VT(&keys));
842 VariantClear(&keys);
843
844 V_VT(&key) = VT_R4;
845 V_R4(&key) = 0.0;
847 hr = IDictionary_Add(dict, &key, &item);
848 ok(hr == S_OK, "got 0x%08x\n", hr);
849
850 VariantInit(&keys);
851 hr = IDictionary_Keys(dict, &keys);
852 ok(hr == S_OK, "got 0x%08x\n", hr);
853 ok(V_VT(&keys) == (VT_ARRAY|VT_VARIANT), "got %d\n", V_VT(&keys));
854
856 index = 0;
857 hr = SafeArrayGetElement(V_ARRAY(&keys), &index, &key);
858 ok(hr == S_OK, "got 0x%08x\n", hr);
859 ok(V_VT(&key) == VT_R4, "got %d\n", V_VT(&key));
860
861 index = SafeArrayGetDim(V_ARRAY(&keys));
862 ok(index == 1, "got %d\n", index);
863
864 hr = SafeArrayGetUBound(V_ARRAY(&keys), 1, &index);
865 ok(hr == S_OK, "got 0x%08x\n", hr);
866 ok(index == 0, "got %d\n", index);
867
868 VariantClear(&keys);
869
870 IDictionary_Release(dict);
871}
#define index(s, c)
Definition: various.h:29
@ VT_ARRAY
Definition: compat.h:2341
@ VT_VARIANT
Definition: compat.h:2307
HRESULT WINAPI SafeArrayGetUBound(SAFEARRAY *psa, UINT nDim, LONG *plUbound)
Definition: safearray.c:1033
HRESULT WINAPI SafeArrayGetElement(SAFEARRAY *psa, LONG *rgIndices, void *pvData)
Definition: safearray.c:947
UINT WINAPI SafeArrayGetDim(SAFEARRAY *psa)
Definition: safearray.c:1094
GLuint index
Definition: glext.h:6031
#define V_ARRAY(A)
Definition: oleauto.h:222

Referenced by START_TEST().

◆ test_Remove()

static void test_Remove ( void  )
static

Definition at line 873 of file dictionary.c.

874{
876 IDictionary *dict;
877 HRESULT hr;
878
879 hr = CoCreateInstance(&CLSID_Dictionary, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
880 &IID_IDictionary, (void**)&dict);
881 ok(hr == S_OK, "got 0x%08x\n", hr);
882
883if (0)
884 hr = IDictionary_Remove(dict, NULL);
885
886 /* nothing added yet */
887 V_VT(&key) = VT_R4;
888 V_R4(&key) = 0.0;
889 hr = IDictionary_Remove(dict, &key);
890 ok(hr == CTL_E_ELEMENT_NOT_FOUND, "got 0x%08x\n", hr);
891
893 hr = IDictionary_Add(dict, &key, &item);
894 ok(hr == S_OK, "got 0x%08x\n", hr);
895
896 hr = IDictionary_Remove(dict, &key);
897 ok(hr == S_OK, "got 0x%08x\n", hr);
898
899 IDictionary_Release(dict);
900}

Referenced by START_TEST().

◆ test_unk_AddRef()

static ULONG WINAPI test_unk_AddRef ( IUnknown iface)
static

Definition at line 246 of file dictionary.c.

247{
248 ok(0, "unexpected\n");
249 return 2;
250}

◆ test_unk_no_QI()

static HRESULT WINAPI test_unk_no_QI ( IUnknown iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 240 of file dictionary.c.

241{
242 *obj = NULL;
243 return E_NOINTERFACE;
244}

◆ test_unk_QI()

static HRESULT WINAPI test_unk_QI ( IUnknown iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 228 of file dictionary.c.

229{
231 *obj = iface;
232 return S_OK;
233 }
234
235 ok(0, "unexpected %s\n", wine_dbgstr_guid(riid));
236 *obj = NULL;
237 return E_NOINTERFACE;
238}

◆ test_unk_Release()

static ULONG WINAPI test_unk_Release ( IUnknown iface)
static

Definition at line 252 of file dictionary.c.

253{
254 return 1;
255}

Variable Documentation

◆ test_disp

IDispatch test_disp = { &test_disp_vtbl }
static

Definition at line 330 of file dictionary.c.

Referenced by test_hash_value().

◆ test_disp_vtbl

const IDispatchVtbl test_disp_vtbl
static
Initial value:
= {
}
static ULONG WINAPI test_disp_AddRef(IDispatch *iface)
Definition: dictionary.c:281
static HRESULT WINAPI test_disp_GetTypeInfo(IDispatch *iface, UINT index, LCID lcid, ITypeInfo **ti)
Definition: dictionary.c:298
static HRESULT WINAPI test_disp_QI(IDispatch *iface, REFIID riid, void **obj)
Definition: dictionary.c:269
static ULONG WINAPI test_disp_Release(IDispatch *iface)
Definition: dictionary.c:287
static HRESULT WINAPI test_disp_Invoke(IDispatch *iface, DISPID dispid, REFIID riid, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *excepinfo, UINT *arg_err)
Definition: dictionary.c:311
static HRESULT WINAPI test_disp_GetTypeInfoCount(IDispatch *iface, UINT *count)
Definition: dictionary.c:292
static HRESULT WINAPI test_disp_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *names, UINT name_count, LCID lcid, DISPID *dispid)
Definition: dictionary.c:304

Definition at line 318 of file dictionary.c.

◆ test_unk

IUnknown test_unk = { &test_unk_vtbl }
static

Definition at line 328 of file dictionary.c.

Referenced by test_hash_value().

◆ test_unk2

IUnknown test_unk2 = { &test_unk_no_vtbl }
static

Definition at line 329 of file dictionary.c.

Referenced by test_hash_value().

◆ test_unk_no_vtbl

const IUnknownVtbl test_unk_no_vtbl
static
Initial value:
= {
}
static HRESULT WINAPI test_unk_no_QI(IUnknown *iface, REFIID riid, void **obj)
Definition: dictionary.c:240
static ULONG WINAPI test_unk_AddRef(IUnknown *iface)
Definition: dictionary.c:246
static ULONG WINAPI test_unk_Release(IUnknown *iface)
Definition: dictionary.c:252

Definition at line 263 of file dictionary.c.

◆ test_unk_vtbl

const IUnknownVtbl test_unk_vtbl
static
Initial value:
= {
}
static HRESULT WINAPI test_unk_QI(IUnknown *iface, REFIID riid, void **obj)
Definition: dictionary.c:228

Definition at line 257 of file dictionary.c.