2 * Copyright (C) 2012 Alistair Leslie-Hughes
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/test.h"
31 static void test_interfaces(void)
33 static const WCHAR key_add
[] = {'a', 0};
34 static const WCHAR key_add_value
[] = {'a', 0};
35 static const WCHAR key_non_exist
[] = {'b', 0};
40 IObjectWithSite
*site
;
45 hr
= CoCreateInstance(&CLSID_Dictionary
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
46 &IID_IDispatch
, (void**)&disp
);
47 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
52 hr
= IDispatch_QueryInterface(disp
, &IID_IDictionary
, (void**)&dict
);
53 ok(hr
== S_OK
, "got 0x%08x, expected 0x%08x\n", hr
, S_OK
);
55 hr
= IDispatch_QueryInterface(disp
, &IID_IObjectWithSite
, (void**)&site
);
56 ok(hr
== E_NOINTERFACE
, "got 0x%08x, expected 0x%08x\n", hr
, E_NOINTERFACE
);
58 hr
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
59 ok(hr
== E_NOINTERFACE
, "got 0x%08x, expected 0x%08x\n", hr
, E_NOINTERFACE
);
62 V_BSTR(&key
) = SysAllocString(key_add
);
63 V_VT(&value
) = VT_BSTR
;
64 V_BSTR(&value
) = SysAllocString(key_add_value
);
65 hr
= IDictionary_Add(dict
, &key
, &value
);
66 todo_wine
ok(hr
== S_OK
, "got 0x%08x, expected 0x%08x\n", hr
, S_OK
);
69 exists
= VARIANT_FALSE
;
70 hr
= IDictionary_Exists(dict
, &key
, &exists
);
71 todo_wine
ok(hr
== S_OK
, "got 0x%08x, expected 0x%08x\n", hr
, S_OK
);
72 todo_wine
ok(exists
== VARIANT_TRUE
, "Expected TRUE but got FALSE.\n");
75 exists
= VARIANT_TRUE
;
77 V_BSTR(&key
) = SysAllocString(key_non_exist
);
78 hr
= IDictionary_Exists(dict
, &key
, &exists
);
79 todo_wine
ok(hr
== S_OK
, "got 0x%08x, expected 0x%08x\n", hr
, S_OK
);
80 todo_wine
ok(exists
== VARIANT_FALSE
, "Expected FALSE but got TRUE.\n");
83 hr
= IDictionary_get_Count(dict
, &count
);
84 ok(hr
== S_OK
, "got 0x%08x, expected 0x%08x\n", hr
, S_OK
);
85 todo_wine
ok(count
== 1, "got %d, expected 1\n", count
);
87 IDictionary_Release(dict
);
88 IDispatch_Release(disp
);
91 static void test_comparemode(void)
97 hr
= CoCreateInstance(&CLSID_Dictionary
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
98 &IID_IDictionary
, (void**)&dict
);
99 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
101 if (0) /* crashes on native */
102 hr
= IDictionary_get_CompareMode(dict
, NULL
);
105 hr
= IDictionary_get_CompareMode(dict
, &method
);
106 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
107 ok(method
== BinaryCompare
, "got %d\n", method
);
109 /* invalid mode value is not checked */
110 hr
= IDictionary_put_CompareMode(dict
, 10);
111 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
113 hr
= IDictionary_get_CompareMode(dict
, &method
);
114 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
115 ok(method
== 10, "got %d\n", method
);
117 hr
= IDictionary_put_CompareMode(dict
, DatabaseCompare
);
118 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
120 hr
= IDictionary_get_CompareMode(dict
, &method
);
121 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
122 ok(method
== DatabaseCompare
, "got %d\n", method
);
124 IDictionary_Release(dict
);
127 START_TEST(dictionary
)
134 hr
= CoCreateInstance(&CLSID_Dictionary
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
135 &IID_IDispatch
, (void**)&disp
);
137 win_skip("Dictionary object is not supported: %08x\n", hr
);
141 IDispatch_Release(disp
);