[3/3] shlwapi/tests: Skip the string tests for the functions that are not available on Win9x.

Francois Gouget fgouget at free.fr
Sat Mar 1 14:18:23 CST 2008


---

This should get the shlwapi tests running on Win9x again.

 dlls/shlwapi/tests/string.c |  131 ++++++++++++++++++++++++++++++++----------
 1 files changed, 100 insertions(+), 31 deletions(-)

diff --git a/dlls/shlwapi/tests/string.c b/dlls/shlwapi/tests/string.c
index 0ff37c7..809d384 100644
--- a/dlls/shlwapi/tests/string.c
+++ b/dlls/shlwapi/tests/string.c
@@ -479,12 +479,20 @@ static void test_StrDupA(void)
 
 static void test_StrFormatByteSize64A(void)
 {
+  LPSTR (WINAPI *pStrFormatByteSize64A)(LONGLONG,LPSTR,UINT);
   char szBuff[256];
   const StrFormatSizeResult* result = StrFormatSize_results;
 
+  pStrFormatByteSize64A = (void *)GetProcAddress(hShlwapi, "StrFormatByteSize64A");
+  if (!pStrFormatByteSize64A)
+  {
+    skip("StrFormatByteSize64A() is not available. Tests skipped\n");
+    return;
+  }
+
   while(result->value)
   {
-    StrFormatByteSize64A(result->value, szBuff, 256);
+      pStrFormatByteSize64A(result->value, szBuff, 256);
 
     ok(!strcmp(result->byte_size_64, szBuff),
         "Formatted %x%08x wrong: got %s, expected %s\n",
@@ -496,13 +504,21 @@ static void test_StrFormatByteSize64A(void)
 
 static void test_StrFormatKBSizeW(void)
 {
+  LPWSTR (WINAPI *pStrFormatKBSizeW)(LONGLONG,LPWSTR,UINT);
   WCHAR szBuffW[256];
   char szBuff[256];
   const StrFormatSizeResult* result = StrFormatSize_results;
 
+  pStrFormatKBSizeW = (void *)GetProcAddress(hShlwapi, "StrFormatKBSizeW");
+  if (!pStrFormatKBSizeW)
+  {
+    skip("StrFormatKBSizeW() is not available. Tests skipped\n");
+    return;
+  }
+
   while(result->value)
   {
-    StrFormatKBSizeW(result->value, szBuffW, 256);
+    pStrFormatKBSizeW(result->value, szBuffW, 256);
     WideCharToMultiByte(0,0,szBuffW,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR),0,0);
     ok(!strcmp(result->kb_size, szBuff),
         "Formatted %x%08x wrong: got %s, expected %s\n",
@@ -513,12 +529,20 @@ static void test_StrFormatKBSizeW(void)
 
 static void test_StrFormatKBSizeA(void)
 {
+  LPSTR (WINAPI *pStrFormatKBSizeA)(LONGLONG,LPSTR,UINT);
   char szBuff[256];
   const StrFormatSizeResult* result = StrFormatSize_results;
 
+  pStrFormatKBSizeA = (void *)GetProcAddress(hShlwapi, "StrFormatKBSizeA");
+  if (!pStrFormatKBSizeA)
+  {
+    skip("StrFormatKBSizeA() is not available. Tests skipped\n");
+    return;
+  }
+
   while(result->value)
   {
-    StrFormatKBSizeA(result->value, szBuff, 256);
+    pStrFormatKBSizeA(result->value, szBuff, 256);
 
     ok(!strcmp(result->kb_size, szBuff),
         "Formatted %x%08x wrong: got %s, expected %s\n",
@@ -785,6 +809,12 @@ static void test_SHUnicodeToUnicode(void)
 
 static void test_StrXXX_overflows(void)
 {
+    LPSTR (WINAPI *pStrCatBuffA)(LPSTR,LPCSTR,INT);
+    LPWSTR (WINAPI *pStrCatBuffW)(LPWSTR,LPCWSTR,INT);
+    HRESULT (WINAPI *pStrRetToBufA)(STRRET*,LPCITEMIDLIST,LPSTR,UINT);
+    HRESULT (WINAPI *pStrRetToBufW)(STRRET*,LPCITEMIDLIST,LPWSTR,UINT);
+    INT (WINAPIV *pwnsprintfA)(LPSTR,INT,LPCSTR, ...);
+    INT (WINAPIV *pwnsprintfW)(LPWSTR,INT,LPCWSTR, ...);
     CHAR str1[2*MAX_PATH+1], buf[2*MAX_PATH];
     WCHAR wstr1[2*MAX_PATH+1], wbuf[2*MAX_PATH];
     const WCHAR fmt[] = {'%','s',0};
@@ -804,42 +834,81 @@ static void test_StrXXX_overflows(void)
     expect_eq(StrCpyNA(buf, str1, 10), buf, PCHAR, "%p");
     expect_eq(buf[9], 0, CHAR, "%x");
     expect_eq(buf[10], '\xbf', CHAR, "%x");
-    expect_eq(StrCatBuffA(buf, str1, 100), buf, PCHAR, "%p");
-    expect_eq(buf[99], 0, CHAR, "%x");
-    expect_eq(buf[100], '\xbf', CHAR, "%x");
+
+    pStrCatBuffA = (void *)GetProcAddress(hShlwapi, "StrCatBuffA");
+    if (pStrCatBuffA)
+    {
+        expect_eq(pStrCatBuffA(buf, str1, 100), buf, PCHAR, "%p");
+        expect_eq(buf[99], 0, CHAR, "%x");
+        expect_eq(buf[100], '\xbf', CHAR, "%x");
+    }
+    else
+        skip("StrCatBuffA() is not available. Tests skipped\n");
 
     memset(wbuf, 0xbf, sizeof(wbuf));
     expect_eq(StrCpyNW(wbuf, wstr1, 10), wbuf, PWCHAR, "%p");
     expect_eq(wbuf[9], 0, WCHAR, "%x");
     expect_eq(wbuf[10], (WCHAR)0xbfbf, WCHAR, "%x");
-    expect_eq(StrCatBuffW(wbuf, wstr1, 100), wbuf, PWCHAR, "%p");
-    expect_eq(wbuf[99], 0, WCHAR, "%x");
-    expect_eq(wbuf[100], (WCHAR)0xbfbf, WCHAR, "%x");
 
-    memset(wbuf, 0xbf, sizeof(wbuf));
-    strret.uType = STRRET_WSTR;
-    U(strret).pOleStr = StrDupW(wstr1);
-    expect_eq(StrRetToBufW(&strret, NULL, wbuf, 10), S_OK, HRESULT, "%x");
-    expect_eq(wbuf[9], 0, WCHAR, "%x");
-    expect_eq(wbuf[10], (WCHAR)0xbfbf, WCHAR, "%x");
+    pStrCatBuffW = (void *)GetProcAddress(hShlwapi, "StrCatBuffW");
+    if (pStrCatBuffW)
+    {
+        expect_eq(pStrCatBuffW(wbuf, wstr1, 100), wbuf, PWCHAR, "%p");
+        expect_eq(wbuf[99], 0, WCHAR, "%x");
+        expect_eq(wbuf[100], (WCHAR)0xbfbf, WCHAR, "%x");
+    }
+    else
+        skip("StrCatBuffW() is not available. Tests skipped\n");
 
-    memset(buf, 0xbf, sizeof(buf));
-    strret.uType = STRRET_CSTR;
-    StrCpyN(U(strret).cStr, str1, MAX_PATH);
-    expect_eq(StrRetToBufA(&strret, NULL, buf, 10), S_OK, HRESULT, "%x");
-    expect_eq(buf[9], 0, CHAR, "%x");
-    expect_eq(buf[10], (CHAR)0xbf, CHAR, "%x");
+    pStrRetToBufW = (void *)GetProcAddress(hShlwapi, "StrRetToBufW");
+    if (pStrRetToBufW)
+    {
+        memset(wbuf, 0xbf, sizeof(wbuf));
+        strret.uType = STRRET_WSTR;
+        U(strret).pOleStr = StrDupW(wstr1);
+        expect_eq(pStrRetToBufW(&strret, NULL, wbuf, 10), S_OK, HRESULT, "%x");
+        expect_eq(wbuf[9], 0, WCHAR, "%x");
+        expect_eq(wbuf[10], (WCHAR)0xbfbf, WCHAR, "%x");
+    }
+    else
+        skip("StrRetToBufW() is not available. Tests skipped\n");
 
-    memset(buf, 0xbf, sizeof(buf));
-    ret = wnsprintfA(buf, 10, "%s", str1);
-    todo_wine ok(ret == 9, "Unexpected wsnprintfA return %d, expected 9\n", ret);
-    expect_eq(buf[9], 0, CHAR, "%x");
-    expect_eq(buf[10], (CHAR)0xbf, CHAR, "%x");
-    memset(wbuf, 0xbf, sizeof(wbuf));
-    ret = wnsprintfW(wbuf, 10, fmt, wstr1);
-    todo_wine ok(ret == 9, "Unexpected wsnprintfW return %d, expected 9\n", ret);
-    expect_eq(wbuf[9], 0, WCHAR, "%x");
-    expect_eq(wbuf[10], (WCHAR)0xbfbf, WCHAR, "%x");
+    pStrRetToBufA = (void *)GetProcAddress(hShlwapi, "StrRetToBufA");
+    if (pStrRetToBufA)
+    {
+        memset(buf, 0xbf, sizeof(buf));
+        strret.uType = STRRET_CSTR;
+        StrCpyN(U(strret).cStr, str1, MAX_PATH);
+        expect_eq(pStrRetToBufA(&strret, NULL, buf, 10), S_OK, HRESULT, "%x");
+        expect_eq(buf[9], 0, CHAR, "%x");
+        expect_eq(buf[10], (CHAR)0xbf, CHAR, "%x");
+    }
+    else
+        skip("StrRetToBufA() is not available. Tests skipped\n");
+
+    pwnsprintfA = (void *)GetProcAddress(hShlwapi, "wnsprintfA");
+    if (pwnsprintfA)
+    {
+        memset(buf, 0xbf, sizeof(buf));
+        ret = pwnsprintfA(buf, 10, "%s", str1);
+        todo_wine ok(ret == 9, "Unexpected wsnprintfA return %d, expected 9\n", ret);
+        expect_eq(buf[9], 0, CHAR, "%x");
+        expect_eq(buf[10], (CHAR)0xbf, CHAR, "%x");
+    }
+    else
+        skip("wnsprintfA() is not available. Tests skipped\n");
+
+    pwnsprintfW = (void *)GetProcAddress(hShlwapi, "wnsprintfW");
+    if (pwnsprintfW)
+    {
+        memset(wbuf, 0xbf, sizeof(wbuf));
+        ret = pwnsprintfW(wbuf, 10, fmt, wstr1);
+        todo_wine ok(ret == 9, "Unexpected wsnprintfW return %d, expected 9\n", ret);
+        expect_eq(wbuf[9], 0, WCHAR, "%x");
+        expect_eq(wbuf[10], (WCHAR)0xbfbf, WCHAR, "%x");
+    }
+    else
+        skip("wnsprintfW() is not available. Tests skipped\n");
 }
 
 START_TEST(string)
-- 
1.5.4.1




More information about the wine-patches mailing list