From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/propsys/tests/propsys.c | 93 +++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-)
diff --git a/dlls/propsys/tests/propsys.c b/dlls/propsys/tests/propsys.c index d63b9ddd3b2..b266813cc91 100644 --- a/dlls/propsys/tests/propsys.c +++ b/dlls/propsys/tests/propsys.c @@ -1421,6 +1421,97 @@ static void test_PropVariantChangeType_LPWSTR(void) PropVariantClear(&src); }
+static void test_PropVariantChangeType_UI4(void) +{ + static const struct + { + const char *strA; + const WCHAR *str; + unsigned int value; + HRESULT hr; + } + string_to_ui4[] = + { + { "0x123", L"0x123", 0x123 }, + { "1", L"1", 1 }, + { "+1", L"+1", 1 }, + + { "-1", L"-1", 0, TYPE_E_TYPEMISMATCH }, + }; + PROPVARIANT dest, src; + size_t len; + HRESULT hr; + + PropVariantInit(&dest); + + src.vt = VT_NULL; + dest.vt = VT_UI2; + dest.ulVal = 0xffbb; + hr = PropVariantChangeType(&dest, &src, 0, VT_UI4); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + ok(dest.vt == VT_UI4, "Unexpected type %d.\n", dest.vt); + ok(dest.ulVal == 0, "Unexpected value %u.\n", dest.uiVal); + } + + for (int i = 0; i < ARRAY_SIZE(string_to_ui4); ++i) + { + len = strlen(string_to_ui4[i].strA); + src.vt = VT_LPSTR; + src.pszVal = CoTaskMemAlloc(len + 1); + strcpy(src.pszVal, string_to_ui4[i].strA); + dest.vt = VT_UI2; + dest.ulVal = 0xffbb; + hr = PropVariantChangeType(&dest, &src, 0, VT_UI4); + todo_wine_if(i == 3) + ok(hr == string_to_ui4[i].hr, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + ok(dest.vt == VT_UI4, "Unexpected type %d.\n", dest.vt); + ok(dest.ulVal == string_to_ui4[i].value, "Unexpected value %lu.\n", dest.ulVal); + } + else + { + todo_wine + ok(dest.vt == VT_EMPTY, "Unexpected type %d.\n", dest.vt); + todo_wine + ok(!dest.ulVal, "Unexpected value %lu.\n", dest.ulVal); + } + PropVariantClear(&src); + + len = lstrlenW(string_to_ui4[i].str); + src.vt = VT_LPWSTR; + src.pwszVal = CoTaskMemAlloc((len + 1) * sizeof(WCHAR)); + lstrcpyW(src.pwszVal, string_to_ui4[i].str); + dest.vt = VT_UI2; + dest.ulVal = 0xffbb; + hr = PropVariantChangeType(&dest, &src, 0, VT_UI4); + todo_wine_if(i == 3) + ok(hr == string_to_ui4[i].hr, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + ok(dest.vt == VT_UI4, "Unexpected type %d.\n", dest.vt); + ok(dest.ulVal == string_to_ui4[i].value, "Unexpected value %lu.\n", dest.ulVal); + } + else + { + todo_wine + ok(dest.vt == VT_EMPTY, "Unexpected type %d.\n", dest.vt); + todo_wine + ok(!dest.ulVal, "Unexpected value %lu.\n", dest.ulVal); + } + PropVariantClear(&src); + } +} + +static void test_PropVariantChangeType(void) +{ + test_PropVariantChangeType_LPWSTR(); + test_PropVariantChangeType_UI4(); +} + static void test_InitPropVariantFromCLSID(void) { PROPVARIANT propvar; @@ -2641,7 +2732,7 @@ START_TEST(propsys) test_PropVariantToStringAlloc(); test_PropVariantCompareEx(); test_intconversions(); - test_PropVariantChangeType_LPWSTR(); + test_PropVariantChangeType(); test_PropVariantToBoolean(); test_PropVariantToStringWithDefault(); test_PropVariantToDouble();
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/propsys/propvar.c | 26 ++++++++++++++++++++++++++ dlls/propsys/tests/propsys.c | 9 ++++++++- 2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/dlls/propsys/propvar.c b/dlls/propsys/propvar.c index d681b910e90..4de24d945d4 100644 --- a/dlls/propsys/propvar.c +++ b/dlls/propsys/propvar.c @@ -401,6 +401,28 @@ HRESULT WINAPI PropVariantToString(REFPROPVARIANT propvarIn, PWSTR ret, UINT cch return hr; }
+static HRESULT string_alloc_from_uint(ULONG64 value, WCHAR **ret) +{ + WCHAR buffer[64], *out = buffer + ARRAY_SIZE(buffer) - 1; + + *out-- = 0; + + do + { + unsigned int next_digit = value % 10; + *out-- = '0' + next_digit; + value = (value - next_digit) / 10; + } while (value); + + out++; + + if (!(*ret = CoTaskMemAlloc((wcslen(out) + 1) * sizeof(*out)))) + return E_OUTOFMEMORY; + wcscpy(*ret, out); + + return S_OK; +} + HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret) { WCHAR *res = NULL; @@ -450,6 +472,10 @@ HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret) } break;
+ case VT_UI2: + hr = string_alloc_from_uint(propvarIn->uiVal, &res); + break; + default: FIXME("Unsupported conversion (%d)\n", propvarIn->vt); hr = E_FAIL; diff --git a/dlls/propsys/tests/propsys.c b/dlls/propsys/tests/propsys.c index b266813cc91..24d06a95cb7 100644 --- a/dlls/propsys/tests/propsys.c +++ b/dlls/propsys/tests/propsys.c @@ -670,6 +670,13 @@ static void test_PropVariantToStringAlloc(void) ok(hres == S_OK, "PropVariantToStringAlloc returned %#lx.\n", hres); ok(!wcscmp(str, dummy_guid_str), "Unexpected str %s.\n", debugstr_w(str)); CoTaskMemFree(str); + + prop.vt = VT_UI2; + prop.uiVal = 123; + hres = PropVariantToStringAlloc(&prop, &str); + ok(hres == S_OK, "PropVariantToStringAlloc returned %#lx.\n", hres); + ok(!wcscmp(str, L"123"), "Unexpected str %s.\n", debugstr_w(str)); + CoTaskMemFree(str); }
static void test_PropVariantCompareEx(void) @@ -1764,13 +1771,13 @@ static void test_PropVariantToBSTR(void) check_PropVariantToBSTR(VT_I4, lVal, -789, L"-789"); check_PropVariantToBSTR(VT_I8, hVal.QuadPart, -101112, L"-101112"); check_PropVariantToBSTR(VT_UI1, bVal, 0xcd, L"205"); - check_PropVariantToBSTR(VT_UI2, uiVal, 0xdead, L"57005"); check_PropVariantToBSTR(VT_UI4, ulVal, 0xdeadbeef, L"3735928559"); check_PropVariantToBSTR(VT_UI8, uhVal.QuadPart, 0xdeadbeefdeadbeef, L"16045690984833335023"); check_PropVariantToBSTR(VT_BOOL, boolVal, TRUE, L"1"); check_PropVariantToBSTR(VT_R4, fltVal, 0.125f, L"0.125"); check_PropVariantToBSTR(VT_R8, dblVal, 0.456, L"0.456"); } + check_PropVariantToBSTR(VT_UI2, uiVal, 57005, L"57005"); check_PropVariantToBSTR(VT_CLSID, puuid, (CLSID *)&dummy_guid, dummy_guid_str); check_PropVariantToBSTR(VT_LPSTR, pszVal, (char *)topic, topicW); check_PropVariantToBSTR(VT_LPWSTR, pwszVal, (WCHAR *)topicW, topicW);
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=150958
Your paranoid android.
=== debian11b (64 bit WoW report) ===
user32: input.c:4305: Test succeeded inside todo block: button_down_hwnd_todo 1: got MSG_TEST_WIN hwnd 00000000026500FE, msg WM_LBUTTONDOWN, wparam 0x1, lparam 0x320032
Alfred Agrell (@Alcaro) commented about dlls/propsys/propvar.c:
return hr;
}
+static HRESULT string_alloc_from_uint(ULONG64 value, WCHAR **ret) +{
- WCHAR buffer[64], *out = buffer + ARRAY_SIZE(buffer) - 1;
- *out-- = 0;
- do
- {
unsigned int next_digit = value % 10;
*out-- = '0' + next_digit;
value = (value - next_digit) / 10;
That subtraction is unnecessary, division rounds toward zero. It just confuses the compiler.