[2/2] shell32/tests: CommandLineToArgvW("") shouldn't truncate returned exe path.

Ilya Basin basinilya at gmail.com
Tue Jul 6 14:37:13 CDT 2010


This is actually [try 2], but since [1/2] fixes the bug, I removed
detailed output from this test.
---
 dlls/shell32/tests/shlexec.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
index b883d0b..47f640f 100644
--- a/dlls/shell32/tests/shlexec.c
+++ b/dlls/shell32/tests/shlexec.c
@@ -2118,8 +2118,9 @@ static void test_commandline(void)
     static const WCHAR chkfmt3[] = {'\\','\"','%','s','\"',0};
     static const WCHAR chkfmt4[] = {'%','s','=','%','s','\"',' ','%','s','\"',0};
     WCHAR cmdline[255];
-    LPWSTR *args = (LPWSTR*)0xdeadcafe;
+    LPWSTR *args = (LPWSTR*)0xdeadcafe, pbuf;
     INT numargs = -1;
+    size_t buflen;
 
     wsprintfW(cmdline,fmt1,one,two,three,four);
     args=CommandLineToArgvW(cmdline,&numargs);
@@ -2170,6 +2171,15 @@ static void test_commandline(void)
     wsprintfW(cmdline,fmt6);
     args=CommandLineToArgvW(cmdline,&numargs);
     ok(numargs == 1, "expected 1 args, got %i\n",numargs);
+    if (numargs == 1) {
+        buflen = max(lstrlenW(args[0])+1,256);
+        pbuf = HeapAlloc(GetProcessHeap(), 0, buflen*sizeof(pbuf[0]));
+        GetModuleFileNameW(NULL, pbuf, buflen);
+        pbuf[buflen-1] = 0;
+        /* check args[0] is module file name */
+        ok(lstrcmpW(args[0],pbuf)==0, "wrong path to the current executable\n");
+        HeapFree(GetProcessHeap(), 0, pbuf);
+    }
 }
 
 START_TEST(shlexec)
-- 
1.7.1.1




More information about the wine-patches mailing list