[1/3] shlwapi/tests: Move the function pointers to the string test functions where they are initialized and used.

Francois Gouget fgouget at free.fr
Sat Mar 1 14:16:09 CST 2008


---

It makes no sense to declare the function pointers globally, but then 
only initialiaze them in one function or another. This is a recipe for 
adding code that calls the function pointer elsewhere... and before it 
has been initialized of course.

So since the whole test considers that each function pointer is 
initialized and used in only one test_xxx() function, move the pointer 
declarations there.

 dlls/shlwapi/tests/string.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/dlls/shlwapi/tests/string.c b/dlls/shlwapi/tests/string.c
index 9186da0..0ff37c7 100644
--- a/dlls/shlwapi/tests/string.c
+++ b/dlls/shlwapi/tests/string.c
@@ -36,15 +36,6 @@
 } while (0);
 
 static HMODULE hShlwapi;
-static LPSTR   (WINAPI *pStrCpyNXA)(LPSTR,LPCSTR,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 *pSHUnicodeToUnicode)(LPCWSTR,LPWSTR,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 *pIntlStrEqWorkerW)(BOOL,LPCWSTR,LPCWSTR,int);
 
 static int strcmpW(const WCHAR *str1, const WCHAR *str2)
 {
@@ -553,6 +544,8 @@ static void test_StrFromTimeIntervalA(void)
 
 static void test_StrCmpA(void)
 {
+  BOOL (WINAPI *pStrIsIntlEqualA)(BOOL,LPCSTR,LPCSTR,int);
+  BOOL (WINAPI *pIntlStrEqWorkerA)(BOOL,LPCSTR,LPCSTR,int);
   static const char str1[] = {'a','b','c','d','e','f'};
   static const char str2[] = {'a','B','c','d','e','f'};
   ok(0 != StrCmpNA(str1, str2, 6), "StrCmpNA is case-insensitive\n");
@@ -582,6 +575,8 @@ static void test_StrCmpA(void)
 
 static void test_StrCmpW(void)
 {
+  BOOL (WINAPI *pStrIsIntlEqualW)(BOOL,LPCWSTR,LPCWSTR,int);
+  BOOL (WINAPI *pIntlStrEqWorkerW)(BOOL,LPCWSTR,LPCWSTR,int);
   static const WCHAR str1[] = {'a','b','c','d','e','f'};
   static const WCHAR str2[] = {'a','B','c','d','e','f'};
   ok(0 != StrCmpNW(str1, str2, 5), "StrCmpNW is case-insensitive\n");
@@ -619,6 +614,7 @@ static WCHAR *CoDupStrW(const char* src)
 
 static void test_StrRetToBSTR(void)
 {
+    HRESULT (WINAPI *pStrRetToBSTR)(STRRET*,void*,BSTR*);
     static const WCHAR szTestW[] = { 'T','e','s','t','\0' };
     ITEMIDLIST iidl[10];
     BSTR bstr;
@@ -663,6 +659,7 @@ static void test_StrRetToBSTR(void)
 
 static void test_StrCpyNXA(void)
 {
+  LPSTR (WINAPI *pStrCpyNXA)(LPSTR,LPCSTR,int);
   LPCSTR lpSrc = "hello";
   LPSTR lpszRes;
   char dest[8];
@@ -683,6 +680,7 @@ static void test_StrCpyNXA(void)
 
 static void test_StrCpyNXW(void)
 {
+  LPWSTR (WINAPI *pStrCpyNXW)(LPWSTR,LPCWSTR,int);
   static const WCHAR lpInit[] = { '\n','\n','\n','\n','\n','\n','\n','\n' };
   static const WCHAR lpSrc[] = { 'h','e','l','l','o','\0' };
   static const WCHAR lpRes[] = { 'h','e','l','l','o','\0','\n','\n' };
@@ -699,7 +697,7 @@ static void test_StrCpyNXW(void)
   memcpy(dest, lpInit, sizeof(lpInit));
   lpszRes = pStrCpyNXW(dest, lpSrc, sizeof(dest)/sizeof(dest[0]));
   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]);
 }
 
@@ -744,6 +742,7 @@ static void test_StrRStrI(void)
 
 static void test_SHAnsiToAnsi(void)
 {
+  DWORD (WINAPI *pSHAnsiToAnsi)(LPCSTR,LPSTR,int);
   char dest[8];
   DWORD dwRet;
 
@@ -763,6 +762,7 @@ static void test_SHAnsiToAnsi(void)
 
 static void test_SHUnicodeToUnicode(void)
 {
+  DWORD (WINAPI *pSHUnicodeToUnicode)(LPCWSTR,LPWSTR,int);
   static const WCHAR lpInit[] = { '\n','\n','\n','\n','\n','\n','\n','\n' };
   static const WCHAR lpSrc[] = { 'h','e','l','l','o','\0' };
   static const WCHAR lpRes[] = { 'h','e','l','l','o','\0','\n','\n' };
-- 
1.5.4.1




More information about the wine-patches mailing list