oleaut32/tests: Fix test failing on UTF-8 locale.

Method decriptor's strings are internally stored in ANSI, and
potentially converted from Unicode using current code page.

Test was expecting loss in Unicode to ANSI conversion.
Adapt test to also support loss-less conversion (that's the case
when code page is UTF-8).

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52873
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
This commit is contained in:
Eric Pouech 2022-10-20 16:14:38 +02:00 committed by Alexandre Julliard
parent 7afdc11cd2
commit fe5989bbd2

View file

@ -104,6 +104,19 @@ static const BOOL abi_supports_stdcall = TRUE;
static const BOOL abi_supports_stdcall = FALSE;
#endif
static BOOL compare_wstr(const WCHAR* wstr, const WCHAR* ref)
{
char nameA[16];
WCHAR nameW[16];
if (!wcscmp(wstr, ref)) return TRUE; /* for UTF code pages */
WideCharToMultiByte(CP_ACP, 0, ref, -1, nameA, sizeof(nameA), NULL, NULL);
MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, ARRAY_SIZE(nameW));
return !wcscmp(wstr, nameW);
}
static HRESULT WINAPI collection_QueryInterface(ICollection *iface, REFIID riid, void **ret)
{
if (IsEqualIID(riid, &IID_IUnknown) ||
@ -1975,8 +1988,6 @@ static void test_CreateTypeLib(SYSKIND sys) {
TYPEKIND kind;
DESCKIND desckind;
BINDPTR bindptr;
char nameA[16];
WCHAR nameW[16];
switch(sys){
case SYS_WIN32:
@ -2484,9 +2495,6 @@ static void test_CreateTypeLib(SYSKIND sys) {
ok(hres == S_OK, "got %08lx\n", hres);
SysFreeString(V_BSTR(&paramdescex.varDefaultValue));
WideCharToMultiByte(CP_ACP, 0, defaultW, -1, nameA, sizeof(nameA), NULL, NULL);
MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, ARRAY_SIZE(nameW));
hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
ok(hres == S_OK, "got %08lx\n", hres);
@ -2511,7 +2519,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
U(*edesc).paramdesc.pparamdescex->cBytes);
ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), nameW),
ok(compare_wstr(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), defaultW),
"got: %s\n",
wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
@ -2523,7 +2531,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
U(*edesc).paramdesc.pparamdescex->cBytes);
ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), nameW),
ok(compare_wstr(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), defaultW),
"got: %s\n",
wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
@ -3311,7 +3319,7 @@ todo_wine {
U(*edesc).paramdesc.pparamdescex->cBytes);
ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), nameW),
ok(compare_wstr(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), defaultW),
"got: %s\n",
wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
@ -3323,7 +3331,7 @@ todo_wine {
U(*edesc).paramdesc.pparamdescex->cBytes);
ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), nameW),
ok(compare_wstr(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), defaultW),
"got: %s\n",
wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));