Louis Lenders : kernel32/tests: Add some more tests for GetTempFileName.

Alexandre Julliard julliard at winehq.org
Mon Oct 18 13:36:52 CDT 2010


Module: wine
Branch: master
Commit: 933bcb92b0822acb31ad59c9370f8f33f377d416
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=933bcb92b0822acb31ad59c9370f8f33f377d416

Author: Louis Lenders <xerox_xerox2000 at yahoo.co.uk>
Date:   Sun Oct 17 01:51:54 2010 +0200

kernel32/tests: Add some more tests for GetTempFileName.

---

 dlls/kernel32/tests/path.c |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c
index e6d7e56..0200fc4 100644
--- a/dlls/kernel32/tests/path.c
+++ b/dlls/kernel32/tests/path.c
@@ -310,11 +310,14 @@ static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive)
 {
   CHAR tmppath[MAX_PATH], /*path to TEMP */
        tmpstr[MAX_PATH],
-       tmpstr1[MAX_PATH];
+       tmpstr1[MAX_PATH],
+       invalid_dir[MAX_PATH];
+
   DWORD len,len1,drives;
   INT id;
   HANDLE hndl;
   BOOL bRes;
+  UINT unique;
 
   *curDrive = *otherDrive = NOT_A_VALID_DRIVE;
 
@@ -334,11 +337,7 @@ static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive)
   ok(len1==len+1 || broken(len1 == len), /* WinME */
      "GetTempPathA should return string length %d instead of %d\n",len+1,len1);
 
-/* Test GetTmpFileNameA
-   The only test we do here is whether GetTempFileNameA passes or not.
-   We do not thoroughly test this function yet (specifically, whether
-   it behaves correctly when 'unique' is non zero)
-*/
+/* Test GetTmpFileNameA */
   ok((id=GetTempFileNameA(tmppath,"path",0,newdir)),"GetTempFileNameA failed\n");
   sprintf(tmpstr,"pat%.4x.tmp",id & 0xffff);
   sprintf(tmpstr1,"pat%x.tmp",id & 0xffff);
@@ -361,6 +360,24 @@ static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive)
     ok(DeleteFileA(newdir),"Couldn't delete the temporary file we just created\n");
   }
 
+  for(unique=0;unique<3;unique++) {
+    /* Non-existent path */
+    sprintf(invalid_dir, "%s\%s",tmppath,"non_existent_dir_1jwj3y32nb3");
+    SetLastError(0xdeadbeef);
+    todo_wine
+    ok(!GetTempFileNameA(invalid_dir,"tfn",unique,newdir),"GetTempFileNameA should have failed\n");
+    todo_wine
+    ok(GetLastError()==ERROR_DIRECTORY || broken(GetLastError()==ERROR_PATH_NOT_FOUND)/*win98*/,
+    "got %d, expected ERROR_DIRECTORY\n", GetLastError());
+
+    /* Check return value for unique !=0 */
+    if(unique) {
+      ok((GetTempFileNameA(tmppath,"tfn",unique,newdir) == unique),"GetTempFileNameA unexpectedly failed\n");
+      /* if unique != 0, the actual temp files are not created: */
+      ok(!DeleteFileA(newdir) && GetLastError() == ERROR_FILE_NOT_FOUND,"Deleted a file that shouldn't exist!\n");
+    }
+  }
+
 /* Find first valid drive letter that is neither newdir[0] nor curDrive */
   drives = GetLogicalDrives() & ~(1<<(newdir[0]-'A'));
   if( *curDrive != NOT_A_VALID_DRIVE)




More information about the wine-cvs mailing list