Commit d573ca83 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

shlwapi/tests: The function pointers are global so initialize them on startup,…

shlwapi/tests: The function pointers are global so initialize them on startup, before they are used.
parent 34b5e424
...@@ -35,16 +35,15 @@ ...@@ -35,16 +35,15 @@
ok(ret == val, "Unexpected value of '" #expr "': " #fmt " instead of " #val "\n", ret); \ ok(ret == val, "Unexpected value of '" #expr "': " #fmt " instead of " #val "\n", ret); \
} while (0); } while (0);
static HMODULE hShlwapi; static BOOL (WINAPI *pIntlStrEqWorkerA)(BOOL,LPCSTR,LPCSTR,int);
static LPSTR (WINAPI *pStrCpyNXA)(LPSTR,LPCSTR,int); static BOOL (WINAPI *pIntlStrEqWorkerW)(BOOL,LPCWSTR,LPCWSTR,int);
static LPWSTR (WINAPI *pStrCpyNXW)(LPWSTR,LPCWSTR,int);
static HRESULT (WINAPI *pStrRetToBSTR)(STRRET*,void*,BSTR*);
static DWORD (WINAPI *pSHAnsiToAnsi)(LPCSTR,LPSTR,int); static DWORD (WINAPI *pSHAnsiToAnsi)(LPCSTR,LPSTR,int);
static DWORD (WINAPI *pSHUnicodeToUnicode)(LPCWSTR,LPWSTR,int); static DWORD (WINAPI *pSHUnicodeToUnicode)(LPCWSTR,LPWSTR,int);
static LPSTR (WINAPI *pStrCpyNXA)(LPSTR,LPCSTR,int);
static LPWSTR (WINAPI *pStrCpyNXW)(LPWSTR,LPCWSTR,int);
static BOOL (WINAPI *pStrIsIntlEqualA)(BOOL,LPCSTR,LPCSTR,int); static BOOL (WINAPI *pStrIsIntlEqualA)(BOOL,LPCSTR,LPCSTR,int);
static BOOL (WINAPI *pIntlStrEqWorkerA)(BOOL,LPCSTR,LPCSTR,int);
static BOOL (WINAPI *pStrIsIntlEqualW)(BOOL,LPCWSTR,LPCWSTR,int); static BOOL (WINAPI *pStrIsIntlEqualW)(BOOL,LPCWSTR,LPCWSTR,int);
static BOOL (WINAPI *pIntlStrEqWorkerW)(BOOL,LPCWSTR,LPCWSTR,int); static HRESULT (WINAPI *pStrRetToBSTR)(STRRET*,void*,BSTR*);
static int strcmpW(const WCHAR *str1, const WCHAR *str2) static int strcmpW(const WCHAR *str1, const WCHAR *str2)
{ {
...@@ -561,7 +560,6 @@ static void test_StrCmpA(void) ...@@ -561,7 +560,6 @@ static void test_StrCmpA(void)
ok(!ChrCmpIA('b', 'B'), "ChrCmpIA is not case-insensitive\n"); ok(!ChrCmpIA('b', 'B'), "ChrCmpIA is not case-insensitive\n");
ok(ChrCmpIA('a', 'z'), "ChrCmpIA believes that a == z!\n"); ok(ChrCmpIA('a', 'z'), "ChrCmpIA believes that a == z!\n");
pStrIsIntlEqualA = (void *)GetProcAddress(hShlwapi, "StrIsIntlEqualA");
if (pStrIsIntlEqualA) if (pStrIsIntlEqualA)
{ {
ok(pStrIsIntlEqualA(FALSE, str1, str2, 5), "StrIsIntlEqualA(FALSE,...) isn't case-insensitive\n"); ok(pStrIsIntlEqualA(FALSE, str1, str2, 5), "StrIsIntlEqualA(FALSE,...) isn't case-insensitive\n");
...@@ -570,7 +568,6 @@ static void test_StrCmpA(void) ...@@ -570,7 +568,6 @@ static void test_StrCmpA(void)
else else
skip("StrIsIntlEqualA() is not available. Tests skipped\n"); skip("StrIsIntlEqualA() is not available. Tests skipped\n");
pIntlStrEqWorkerA = (void *)GetProcAddress(hShlwapi, "IntlStrEqWorkerA");
if (pIntlStrEqWorkerA) if (pIntlStrEqWorkerA)
{ {
ok(pIntlStrEqWorkerA(FALSE, str1, str2, 5), "IntlStrEqWorkerA(FALSE,...) isn't case-insensitive\n"); ok(pIntlStrEqWorkerA(FALSE, str1, str2, 5), "IntlStrEqWorkerA(FALSE,...) isn't case-insensitive\n");
...@@ -590,7 +587,6 @@ static void test_StrCmpW(void) ...@@ -590,7 +587,6 @@ static void test_StrCmpW(void)
ok(!ChrCmpIW('b', 'B'), "ChrCmpIW is not case-insensitive\n"); ok(!ChrCmpIW('b', 'B'), "ChrCmpIW is not case-insensitive\n");
ok(ChrCmpIW('a', 'z'), "ChrCmpIW believes that a == z!\n"); ok(ChrCmpIW('a', 'z'), "ChrCmpIW believes that a == z!\n");
pStrIsIntlEqualW = (void *)GetProcAddress(hShlwapi, "StrIsIntlEqualW");
if (pStrIsIntlEqualW) if (pStrIsIntlEqualW)
{ {
ok(pStrIsIntlEqualW(FALSE, str1, str2, 5), "StrIsIntlEqualW(FALSE,...) isn't case-insensitive\n"); ok(pStrIsIntlEqualW(FALSE, str1, str2, 5), "StrIsIntlEqualW(FALSE,...) isn't case-insensitive\n");
...@@ -599,7 +595,6 @@ static void test_StrCmpW(void) ...@@ -599,7 +595,6 @@ static void test_StrCmpW(void)
else else
skip("StrIsIntlEqualW() is not available. Tests skipped\n"); skip("StrIsIntlEqualW() is not available. Tests skipped\n");
pIntlStrEqWorkerW = (void *)GetProcAddress(hShlwapi, "IntlStrEqWorkerW");
if (pIntlStrEqWorkerW) if (pIntlStrEqWorkerW)
{ {
ok(pIntlStrEqWorkerW(FALSE, str1, str2, 5), "IntlStrEqWorkerW(FALSE,...) isn't case-insensitive\n"); ok(pIntlStrEqWorkerW(FALSE, str1, str2, 5), "IntlStrEqWorkerW(FALSE,...) isn't case-insensitive\n");
...@@ -625,7 +620,6 @@ static void test_StrRetToBSTR(void) ...@@ -625,7 +620,6 @@ static void test_StrRetToBSTR(void)
STRRET strret; STRRET strret;
HRESULT ret; HRESULT ret;
pStrRetToBSTR = (void *)GetProcAddress(hShlwapi, "StrRetToBSTR");
if (!pStrRetToBSTR) if (!pStrRetToBSTR)
{ {
skip("StrRetToBSTR() is not available. Tests skipped\n"); skip("StrRetToBSTR() is not available. Tests skipped\n");
...@@ -667,7 +661,6 @@ static void test_StrCpyNXA(void) ...@@ -667,7 +661,6 @@ static void test_StrCpyNXA(void)
LPSTR lpszRes; LPSTR lpszRes;
char dest[8]; char dest[8];
pStrCpyNXA = (void *)GetProcAddress(hShlwapi, (LPSTR)399);
if (!pStrCpyNXA) if (!pStrCpyNXA)
{ {
skip("StrCpyNXA() is not available. Tests skipped\n"); skip("StrCpyNXA() is not available. Tests skipped\n");
...@@ -689,7 +682,6 @@ static void test_StrCpyNXW(void) ...@@ -689,7 +682,6 @@ static void test_StrCpyNXW(void)
LPWSTR lpszRes; LPWSTR lpszRes;
WCHAR dest[8]; WCHAR dest[8];
pStrCpyNXW = (void *)GetProcAddress(hShlwapi, (LPSTR)400);
if (!pStrCpyNXW) if (!pStrCpyNXW)
{ {
skip("StrCpyNXW() is not available. Tests skipped\n"); skip("StrCpyNXW() is not available. Tests skipped\n");
...@@ -699,7 +691,7 @@ static void test_StrCpyNXW(void) ...@@ -699,7 +691,7 @@ static void test_StrCpyNXW(void)
memcpy(dest, lpInit, sizeof(lpInit)); memcpy(dest, lpInit, sizeof(lpInit));
lpszRes = pStrCpyNXW(dest, lpSrc, sizeof(dest)/sizeof(dest[0])); lpszRes = pStrCpyNXW(dest, lpSrc, sizeof(dest)/sizeof(dest[0]));
ok(lpszRes == dest + 5 && !memcmp(dest, lpRes, sizeof(dest)), ok(lpszRes == dest + 5 && !memcmp(dest, lpRes, sizeof(dest)),
"StrCpyNXA: expected %p, \"hello\\0\\n\\n\", got %p, \"%d,%d,%d,%d,%d,%d,%d,%d\"\n", "StrCpyNXW: expected %p, \"hello\\0\\n\\n\", got %p, \"%d,%d,%d,%d,%d,%d,%d,%d\"\n",
dest + 5, lpszRes, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]); dest + 5, lpszRes, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
} }
...@@ -747,7 +739,6 @@ static void test_SHAnsiToAnsi(void) ...@@ -747,7 +739,6 @@ static void test_SHAnsiToAnsi(void)
char dest[8]; char dest[8];
DWORD dwRet; DWORD dwRet;
pSHAnsiToAnsi = (void *)GetProcAddress(hShlwapi, (LPSTR)345);
if (!pSHAnsiToAnsi) if (!pSHAnsiToAnsi)
{ {
skip("SHAnsiToAnsi() is not available. Tests skipped\n"); skip("SHAnsiToAnsi() is not available. Tests skipped\n");
...@@ -769,7 +760,6 @@ static void test_SHUnicodeToUnicode(void) ...@@ -769,7 +760,6 @@ static void test_SHUnicodeToUnicode(void)
WCHAR dest[8]; WCHAR dest[8];
DWORD dwRet; DWORD dwRet;
pSHUnicodeToUnicode = (void *)GetProcAddress(hShlwapi, (LPSTR)346);
if (!pSHUnicodeToUnicode) if (!pSHUnicodeToUnicode)
{ {
skip("SHUnicodeToUnicode() is not available. Tests skipped\n"); skip("SHUnicodeToUnicode() is not available. Tests skipped\n");
...@@ -844,6 +834,7 @@ static void test_StrXXX_overflows(void) ...@@ -844,6 +834,7 @@ static void test_StrXXX_overflows(void)
START_TEST(string) START_TEST(string)
{ {
HMODULE hShlwapi;
TCHAR thousandDelim[8]; TCHAR thousandDelim[8];
TCHAR decimalDelim[8]; TCHAR decimalDelim[8];
CoInitialize(0); CoInitialize(0);
...@@ -852,6 +843,15 @@ START_TEST(string) ...@@ -852,6 +843,15 @@ START_TEST(string)
GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimalDelim, 8); GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimalDelim, 8);
hShlwapi = GetModuleHandleA("shlwapi"); hShlwapi = GetModuleHandleA("shlwapi");
pIntlStrEqWorkerA = (void *)GetProcAddress(hShlwapi, "IntlStrEqWorkerA");
pIntlStrEqWorkerW = (void *)GetProcAddress(hShlwapi, "IntlStrEqWorkerW");
pSHAnsiToAnsi = (void *)GetProcAddress(hShlwapi, (LPSTR)345);
pSHUnicodeToUnicode = (void *)GetProcAddress(hShlwapi, (LPSTR)346);
pStrCpyNXA = (void *)GetProcAddress(hShlwapi, (LPSTR)399);
pStrCpyNXW = (void *)GetProcAddress(hShlwapi, (LPSTR)400);
pStrIsIntlEqualA = (void *)GetProcAddress(hShlwapi, "StrIsIntlEqualA");
pStrIsIntlEqualW = (void *)GetProcAddress(hShlwapi, "StrIsIntlEqualW");
pStrRetToBSTR = (void *)GetProcAddress(hShlwapi, "StrRetToBSTR");
test_StrChrA(); test_StrChrA();
test_StrChrW(); test_StrChrW();
......
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