Commit 03a7ddb7 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

mlang: Fix all test failures for NT+ platforms.

parent 94459b88
......@@ -266,6 +266,32 @@ static const char *dump_mime_flags(DWORD flags)
}
#endif
static BOOL check_convertible(IMultiLanguage2 *iML2, UINT from, UINT to)
{
CHAR convert[MAX_PATH];
BYTE dest[MAX_PATH];
HRESULT hr;
UINT srcsz, destsz;
static WCHAR strW[] = {'a','b','c',0};
srcsz = -1;
destsz = MAX_PATH;
hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, from, strW,
&srcsz, convert, &destsz);
if (hr != S_OK)
return FALSE;
srcsz = -1;
destsz = MAX_PATH;
hr = IMultiLanguage2_ConvertString(iML2, NULL, from, to, (BYTE *)convert,
&srcsz, dest, &destsz);
if (hr != S_OK)
return FALSE;
return TRUE;
}
static void test_EnumCodePages(IMultiLanguage2 *iML2, DWORD flags)
{
IEnumCodePage *iEnumCP = NULL;
......@@ -327,6 +353,8 @@ static void test_EnumCodePages(IMultiLanguage2 *iML2, DWORD flags)
CPINFOEXA cpinfoex;
CHARSETINFO csi;
MIMECSETINFO mcsi;
BOOL convertible;
HRESULT check = S_OK;
static const WCHAR autoW[] = {'_','a','u','t','o',0};
#ifdef DUMP_CP_INFO
......@@ -387,12 +415,16 @@ static void test_EnumCodePages(IMultiLanguage2 *iML2, DWORD flags)
ret = IMultiLanguage2_IsConvertible(iML2, CP_UNICODE, cpinfo[i].uiCodePage);
ok(ret == S_OK, "IMultiLanguage2_IsConvertible(CP_UNICODE -> %u) = %08x\n", cpinfo[i].uiCodePage, ret);
convertible = check_convertible(iML2, cpinfo[i].uiCodePage, CP_UTF8);
if (!convertible)
check = S_FALSE;
TRACE_2("Call IMultiLanguage2_IsConvertible\n");
ret = IMultiLanguage2_IsConvertible(iML2, cpinfo[i].uiCodePage, CP_UTF8);
ok(ret == S_OK, "IMultiLanguage2_IsConvertible(%u -> CP_UTF8) = %08x\n", cpinfo[i].uiCodePage, ret);
ok(ret == check, "IMultiLanguage2_IsConvertible(%u -> CP_UTF8) = %08x\n", cpinfo[i].uiCodePage, ret);
TRACE_2("Call IMultiLanguage2_IsConvertible\n");
ret = IMultiLanguage2_IsConvertible(iML2, CP_UTF8, cpinfo[i].uiCodePage);
ok(ret == S_OK, "IMultiLanguage2_IsConvertible(CP_UTF8 -> %u) = %08x\n", cpinfo[i].uiCodePage, ret);
ok(ret == check, "IMultiLanguage2_IsConvertible(CP_UTF8 -> %u) = %08x\n", cpinfo[i].uiCodePage, ret);
}
else
trace("IsValidCodePage failed for cp %u\n", cpinfo[i].uiCodePage);
......@@ -665,12 +697,26 @@ static void IMLangFontLink_Test(IMLangFontLink* iMLFL)
ok(CodePage == 1252, "Incorrect CodePage Returned (%i)\n",CodePage);
}
/* copied from libs/wine/string.c */
WCHAR *strstrW(const WCHAR *str, const WCHAR *sub)
{
while (*str)
{
const WCHAR *p1 = str, *p2 = sub;
while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; }
if (!*p2) return (WCHAR *)str;
str++;
}
return NULL;
}
static void test_rfc1766(IMultiLanguage2 *iML2)
{
IEnumRfc1766 *pEnumRfc1766;
RFC1766INFO info;
ULONG n;
HRESULT ret;
BSTR rfcstr;
ret = IMultiLanguage2_EnumRfc1766(iML2, LANG_NEUTRAL, &pEnumRfc1766);
ok(ret == S_OK, "IMultiLanguage2_EnumRfc1766 error %08x\n", ret);
......@@ -686,7 +732,17 @@ static void test_rfc1766(IMultiLanguage2 *iML2)
#endif
ok(n == 1, "couldn't fetch 1 RFC1766INFO structure\n");
ok(IsValidLocale(info.lcid, LCID_SUPPORTED), "invalid lcid %04x\n", info.lcid);
/* verify the Rfc1766 value */
ret = IMultiLanguage2_GetRfc1766FromLcid(iML2, info.lcid, &rfcstr);
ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
/* not an exact 1:1 correspondence between lcid and rfc1766 in the
* mlang database, e.g., nb-no -> 1044 -> no */
ok(strstrW(info.wszRfc1766, rfcstr) != NULL,
"Expected matching locale names\n");
SysFreeString(rfcstr);
}
IEnumRfc1766_Release(pEnumRfc1766);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment