[PATCH 6/6] lz32/tests: Test creation of a file when it already exists.

Saulius Krasuckas saulius.krasuckas at ieee.org
Tue Oct 10 11:45:15 CDT 2006


I don't know whether these calls should be considered as failures.  
GetLastError() returns consistent error code along with OFSTRUCT.nErrCode.  
Hence I left GLE checks in.

---

 dlls/lz32/tests/lzexpand_main.c |   48 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 47 insertions(+), 1 deletions(-)

aa623125a59ca0b23daa30d5533e3c2fba490f98
diff --git a/dlls/lz32/tests/lzexpand_main.c b/dlls/lz32/tests/lzexpand_main.c
index bc69720..6eb4676 100644
--- a/dlls/lz32/tests/lzexpand_main.c
+++ b/dlls/lz32/tests/lzexpand_main.c
@@ -383,9 +383,34 @@ static void test_LZOpenFileA(void)
   ok(retval != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA: error %ld\n", 
      GetLastError());
 
-  /* Check various opening options: */
   memset(&test, 0xA5, sizeof(test));
   full_file_path_name_in_a_CWD(filename_, short_expected, TRUE);
+  SetLastError(0xfaceabee);
+
+  /* Try creating empty file which already should exist. */
+  file = LZOpenFileA(filename_, &test, OF_CREATE);
+  ok(file >= 0, "LZOpenFileA failed on creation\n");
+  todo_wine
+  ok(GetLastError() == ERROR_BAD_PATHNAME ||
+     GetLastError() == ERROR_ALREADY_EXISTS,
+     "GetLastError() returns %ld\n", GetLastError());
+  ok(test.cBytes == sizeof(OFSTRUCT),
+     "LZOpenFileA set test.cBytes to %d\n", test.cBytes);
+  ok(test.nErrCode == ERROR_SUCCESS ||
+     test.nErrCode == ERROR_ALREADY_EXISTS,
+     "LZOpenFileA set test.nErrCode to %d\n", test.nErrCode);
+  ok(lstrcmpA(test.szPathName, expected) == 0 ||
+     lstrcmpA(test.szPathName, short_expected) == 0, /* Win9x */
+     "LZOpenFileA returned '%s', but was expected to return '%s'\n",
+     test.szPathName, expected);
+  LZClose(file);
+
+  retval = GetFileAttributesA(filename_);
+  ok(retval != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA: error %ld\n",
+     GetLastError());
+
+  /* Check various opening options: */
+  memset(&test, 0xA5, sizeof(test));
 
   /* a, for reading. */
   file = LZOpenFileA(filename_, &test, OF_READ);
@@ -795,6 +820,27 @@ static void test_LZOpenFileW(void)
   ok(retval != INVALID_FILE_ATTRIBUTES, "GetFileAttributes: error %ld\n", 
     GetLastError());
 
+  SetLastError(0xfaceabee);
+  /* Try creating empty file which already should exist. */
+  file = LZOpenFileW(filenameW_, &test, OF_CREATE);
+  todo_wine
+  ok(GetLastError() == ERROR_ALREADY_EXISTS,
+     "GetLastError() returns %ld\n", GetLastError());
+  ok(file >= 0, "LZOpenFile failed on creation\n");
+  ok(test.cBytes == sizeof(OFSTRUCT),
+     "LZOpenFileW set test.cBytes to %d\n", test.cBytes);
+  todo_wine
+  ok(test.nErrCode == ERROR_ALREADY_EXISTS,
+     "LZOpenFileW set test.nErrCode to %d\n", test.nErrCode);
+  ok(lstrcmpA(test.szPathName, expected) == 0,
+     "LZOpenFileW returned '%s', but was expected to return '%s'\n",
+     test.szPathName, expected);
+  LZClose(file);
+
+  retval = GetFileAttributesW(filenameW_);
+  ok(retval != INVALID_FILE_ATTRIBUTES, "GetFileAttributes: error %ld\n",
+    GetLastError());
+
   /* Check various opening options: */
   memset(&test, 0xA5, sizeof(test));
 
-- 
1.3.3



More information about the wine-patches mailing list