1
0
Fork 0
mirror of synced 2025-03-07 03:53:26 +01:00

scrrun/dictionary: Handle VT_EMPTY/VT_NULL keys.

This commit is contained in:
Nikolay Sivov 2024-01-04 01:43:16 +01:00 committed by Alexandre Julliard
parent e89bedb70b
commit 564b796e36
2 changed files with 43 additions and 0 deletions

View file

@ -188,6 +188,10 @@ static BOOL is_matching_key(const struct dictionary *dict, const struct keyitem_
{
return hash == pair->hash && numeric_key_eq(key, &pair->key);
}
else if (V_VT(&pair->key) == VT_EMPTY || V_VT(&pair->key) == VT_NULL)
{
return V_VT(&pair->key) == V_VT(key);
}
else
{
WARN("Unexpected key type %#x.\n", V_VT(key));

View file

@ -1009,6 +1009,45 @@ static void test_Add(void)
VariantClear(&item);
/* Empty and null keys. */
hr = IDictionary_RemoveAll(dict);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
V_VT(&key1) = VT_EMPTY;
V_I4(&key1) = 1;
V_VT(&item) = VT_BSTR;
V_BSTR(&item) = SysAllocString(L"empty");
hr = IDictionary_Add(dict, &key1, &item);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
V_VT(&key2) = VT_EMPTY;
V_I4(&key2) = 2;
hr = IDictionary_Add(dict, &key2, &item);
ok(hr == CTL_E_KEY_ALREADY_EXISTS, "Unexpected hr %#lx.\n", hr);
V_VT(&key2) = VT_NULL;
V_I4(&key2) = 2;
hr = IDictionary_Add(dict, &key2, &item);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IDictionary_RemoveAll(dict);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IDictionary_Add(dict, &key2, &item);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IDictionary_Add(dict, &key2, &item);
ok(hr == CTL_E_KEY_ALREADY_EXISTS, "Unexpected hr %#lx.\n", hr);
hr = IDictionary_Add(dict, &key1, &item);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
VariantClear(&item);
IDictionary_Release(dict);
}