shreg test fix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



this patch makes the shlwapi registry test no longer depends on some env
variables being set or not, or being set with a wrong len

A+
Name:          shreg_tst
ChangeLog:     no longer depends on external env strings values
License:       X11
GenDate:       2002/06/27 19:40:53 UTC
ModifiedFiles: dlls/shlwapi/tests/shreg.c
AddedFiles:    
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/shlwapi/tests/shreg.c,v
retrieving revision 1.4
diff -u -u -r1.4 shreg.c
--- dlls/shlwapi/tests/shreg.c	22 Jun 2002 00:08:10 -0000	1.4
+++ dlls/shlwapi/tests/shreg.c	27 Jun 2002 19:40:50 -0000
@@ -28,18 +28,23 @@
 #include "winuser.h"
 #include "shlwapi.h"
 
-static char * sTestpath1 = "%SYSTEMROOT%\\subdir1";
-static char * sTestpath2 = "%USERPROFILE%\\subdir1";
+static char * sTestpath1 = "%LONGSYSTEMVAR%\\subdir1";
+static char * sTestpath2 = "%FOO%\\subdir1";
 
 static char sExpTestpath1[MAX_PATH];
 static char sExpTestpath2[MAX_PATH];
+static unsigned sExpLen1;
+static unsigned sExpLen2;
 
 static char * sEmptyBuffer ="0123456789";
 
-static void create_test_entrys()
+static void create_test_entrys(void)
 {
 	HKEY hKey;
 
+        SetEnvironmentVariableA("LONGSYSTEMVAR", "bar");
+        SetEnvironmentVariableA("FOO", "ImARatherLongButIndeedNeededString");
+
 	ok(!RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Test", &hKey), "RegCreateKeyA failed");
 
 	if (hKey)
@@ -50,9 +55,11 @@
 	   RegCloseKey(hKey);
 	}
 
-	ExpandEnvironmentStringsA(sTestpath1, sExpTestpath1, sizeof(sExpTestpath1));
-	ExpandEnvironmentStringsA(sTestpath2, sExpTestpath2, sizeof(sExpTestpath2));
-	ok(strlen(sExpTestpath2) > 25, "%%USERPROFILE%% is set to a short value on this machine. we cant perform all tests.");
+	sExpLen1 = ExpandEnvironmentStringsA(sTestpath1, sExpTestpath1, sizeof(sExpTestpath1));
+	sExpLen2 = ExpandEnvironmentStringsA(sTestpath2, sExpTestpath2, sizeof(sExpTestpath2));
+
+        ok(sExpLen1 > 0, "Couldn't expand %s\n", sTestpath1);
+        ok(sExpLen2 > 0, "Couldn't expand %s\n", sTestpath2);
 }
 
 static void test_SHGetValue(void)
@@ -159,11 +166,11 @@
 	 * if the unexpanded string fits into the buffer it can get cut when expanded
 	 */
 	strcpy(buf, sEmptyBuffer);
-	dwSize = 24;
+	dwSize = sExpLen2 - 4;
 	dwType = -1;
 	ok( ERROR_MORE_DATA == SHQueryValueExA( hKey, "Test3", NULL, &dwType, buf, &dwSize), "Expected ERROR_MORE_DATA");
-	ok( 0 == strncmp(sExpTestpath2, buf, 24-1), "(%s)", buf);
-	ok( 24-1 == strlen(buf), "(%s)", buf);
+	ok( 0 == strncmp(sExpTestpath2, buf, sExpLen2 - 4 - 1), "(%s)", buf);
+	ok( sExpLen2 - 4 - 1 == strlen(buf), "(%s)", buf);
 	ok( dwSize == nUsedBuffer2, "(%lu,%u)" , dwSize, nUsedBuffer2);
 	ok( dwType == REG_SZ, "(%lu)" , dwType);
 

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux