From 9419e97c3e896c33987018cf65c59e8d211b4153 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 27 Feb 2015 18:18:13 +0300 Subject: [PATCH] scrrun: Implement Exists() method for dictionary. --- dlls/scrrun/dictionary.c | 10 +++++++--- dlls/scrrun/tests/dictionary.c | 19 +++++++------------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/dlls/scrrun/dictionary.c b/dlls/scrrun/dictionary.c index 2306fadfe95..7c776ee4fc3 100644 --- a/dlls/scrrun/dictionary.c +++ b/dlls/scrrun/dictionary.c @@ -368,13 +368,17 @@ static HRESULT WINAPI dictionary_get_Count(IDictionary *iface, LONG *count) return S_OK; } -static HRESULT WINAPI dictionary_Exists(IDictionary *iface, VARIANT *Key, VARIANT_BOOL *pExists) +static HRESULT WINAPI dictionary_Exists(IDictionary *iface, VARIANT *key, VARIANT_BOOL *exists) { dictionary *This = impl_from_IDictionary(iface); - FIXME("(%p)->(%p %p)\n", This, Key, pExists); + TRACE("(%p)->(%s %p)\n", This, debugstr_variant(key), exists); - return E_NOTIMPL; + if (!exists) + return CTL_E_ILLEGALFUNCTIONCALL; + + *exists = get_keyitem_pair(This, key) != NULL ? VARIANT_TRUE : VARIANT_FALSE; + return S_OK; } static HRESULT WINAPI dictionary_Items(IDictionary *iface, VARIANT *pItemsArray) diff --git a/dlls/scrrun/tests/dictionary.c b/dlls/scrrun/tests/dictionary.c index deeea509521..74ab7b93dd6 100644 --- a/dlls/scrrun/tests/dictionary.c +++ b/dlls/scrrun/tests/dictionary.c @@ -69,16 +69,16 @@ static void test_interfaces(void) exists = VARIANT_FALSE; hr = IDictionary_Exists(dict, &key, &exists); - todo_wine ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); - todo_wine ok(exists == VARIANT_TRUE, "Expected TRUE but got FALSE.\n"); + ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); + ok(exists == VARIANT_TRUE, "Expected TRUE but got FALSE.\n"); VariantClear(&key); exists = VARIANT_TRUE; V_VT(&key) = VT_BSTR; V_BSTR(&key) = SysAllocString(key_non_exist); hr = IDictionary_Exists(dict, &key, &exists); - todo_wine ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); - todo_wine ok(exists == VARIANT_FALSE, "Expected FALSE but got TRUE.\n"); + ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); + ok(exists == VARIANT_FALSE, "Expected FALSE but got TRUE.\n"); VariantClear(&key); hr = IDictionary_get_Count(dict, &count); @@ -442,17 +442,15 @@ if (0) /* crashes on native */ V_VT(&key) = VT_I2; V_I2(&key) = 0; hr = IDictionary_Exists(dict, &key, NULL); -todo_wine ok(hr == CTL_E_ILLEGALFUNCTIONCALL, "got 0x%08x\n", hr); V_VT(&key) = VT_I2; V_I2(&key) = 0; exists = VARIANT_TRUE; hr = IDictionary_Exists(dict, &key, &exists); -todo_wine { ok(hr == S_OK, "got 0x%08x\n", hr); ok(exists == VARIANT_FALSE, "got %x\n", exists); -} + VariantInit(&item); hr = IDictionary_Add(dict, &key, &item); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -465,26 +463,23 @@ todo_wine { V_VT(&key) = VT_I2; V_I2(&key) = 0; hr = IDictionary_Exists(dict, &key, NULL); -todo_wine ok(hr == CTL_E_ILLEGALFUNCTIONCALL, "got 0x%08x\n", hr); V_VT(&key) = VT_I2; V_I2(&key) = 0; exists = VARIANT_FALSE; hr = IDictionary_Exists(dict, &key, &exists); -todo_wine { ok(hr == S_OK, "got 0x%08x\n", hr); ok(exists == VARIANT_TRUE, "got %x\n", exists); -} + /* key of different type, but resolves to same hash value */ V_VT(&key) = VT_R4; V_R4(&key) = 0.0; exists = VARIANT_FALSE; hr = IDictionary_Exists(dict, &key, &exists); -todo_wine { ok(hr == S_OK, "got 0x%08x\n", hr); ok(exists == VARIANT_TRUE, "got %x\n", exists); -} + IDictionary_Release(dict); }