ReactOS 0.4.16-dev-297-gc569aee
lzexpand_main.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <stdlib.h>
#include <winerror.h>
#include <lzexpand.h>
#include "wine/test.h"
Include dependency graph for lzexpand_main.c:

Go to the source code of this file.

Functions

static void full_file_path_name_in_a_CWD (const char *src, char *dst, BOOL expect_short)
 
static void create_file (char *fname)
 
static void delete_file (char *fname)
 
static void test_LZOpenFileA_existing_compressed (void)
 
static void test_LZOpenFileA_nonexisting_compressed (void)
 
static void test_LZOpenFileA (void)
 
static void test_LZRead (void)
 
static void test_LZCopy (void)
 
static void create_fileW (WCHAR *fnameW)
 
static void delete_fileW (WCHAR *fnameW)
 
static void test_LZOpenFileW_existing_compressed (void)
 
static void test_LZOpenFileW_nonexisting_compressed (void)
 
static void test_LZOpenFileW (void)
 
 START_TEST (lzexpand_main)
 

Variables

static char filename [] = "testfile.xxx"
 
static char filename_ [] = "testfile.xx_"
 
static WCHAR filenameW [] = {'t','e','s','t','f','i','l','e','.','x','x','x',0}
 
static WCHAR filenameW_ [] = {'t','e','s','t','f','i','l','e','.','x','x','_',0}
 
static char dotless [] = "dotless"
 
static char dotless_ [] = "dotless._"
 
static WCHAR dotlessW [] = {'d','o','t','l','e','s','s', 0}
 
static WCHAR dotlessW_ [] = {'d','o','t','l','e','s','s','.','_', 0}
 
static char extless [] = "extless."
 
static char extless_ [] = "extless._"
 
static WCHAR extlessW [] = {'e','x','t','l','e','s','s','.', 0}
 
static WCHAR extlessW_ [] = {'e','x','t','l','e','s','s','.','_', 0}
 
static char _terminated [] = "_terminated.xxxx_"
 
static char _terminated_ [] = "_terminated.xxxx_"
 
static WCHAR _terminatedW [] = {'_','t','e','r','m','i','n','a','t','e','d','.','x','x','x','x','_', 0}
 
static WCHAR _terminatedW_ [] = {'_','t','e','r','m','i','n','a','t','e','d','.','x','x','x','x','_', 0}
 
static char filename2 [] = "testfile.yyy"
 
static const unsigned char compressed_file []
 
static const DWORD compressed_file_size = sizeof(compressed_file)
 
static const char uncompressed_data [] = "This is a test file."
 
static const DWORD uncompressed_data_size = sizeof(uncompressed_data) - 1
 
static charbuf
 

Function Documentation

◆ create_file()

static void create_file ( char fname)
static

Definition at line 92 of file lzexpand_main.c.

93{
94 INT file;
95 OFSTRUCT ofs;
96 DWORD retval;
97
98 file = LZOpenFileA(fname, &ofs, OF_CREATE);
99 ok(file >= 0, "LZOpenFileA failed to create '%s'\n", fname);
100 LZClose(file);
101 retval = GetFileAttributesA(fname);
102 ok(retval != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA('%s'): error %d\n", ofs.szPathName, GetLastError());
103}
#define ok(value,...)
Definition: atltest.h:57
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:636
unsigned long DWORD
Definition: ntddk_ex.h:95
void WINAPI LZClose(HFILE fd)
Definition: lzexpand.c:595
HFILE WINAPI LZOpenFileA(LPSTR fn, LPOFSTRUCT ofs, WORD mode)
Definition: lzexpand.c:551
CHAR szPathName[OFS_MAXPATHNAME]
Definition: winbase.h:1319
Definition: fci.c:127
int32_t INT
Definition: typedefs.h:58
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define OF_CREATE
Definition: winbase.h:126

◆ create_fileW()

static void create_fileW ( WCHAR fnameW)
static

Definition at line 498 of file lzexpand_main.c.

499{
500 INT file;
501 OFSTRUCT ofs;
502 DWORD retval;
503
504 file = LZOpenFileW(fnameW, &ofs, OF_CREATE);
505 ok(file >= 0, "LZOpenFileW failed on creation\n");
506 LZClose(file);
507 retval = GetFileAttributesW(fnameW);
508 ok(retval != INVALID_FILE_ATTRIBUTES, "GetFileAttributesW('%s'): error %d\n", ofs.szPathName, GetLastError());
509}
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
HFILE WINAPI LZOpenFileW(LPWSTR fn, LPOFSTRUCT ofs, WORD mode)
Definition: lzexpand.c:580

Referenced by test_LZOpenFileW_existing_compressed().

◆ delete_file()

static void delete_file ( char fname)
static

Definition at line 105 of file lzexpand_main.c.

106{
107 INT file;
108 OFSTRUCT ofs;
109 DWORD retval;
110
111 file = LZOpenFileA(fname, &ofs, OF_DELETE);
112 ok(file >= 0, "LZOpenFileA failed to delete '%s'\n", fname);
113 LZClose(file);
114 retval = GetFileAttributesA(fname);
115 ok(retval == INVALID_FILE_ATTRIBUTES, "GetFileAttributesA succeeded on deleted file ('%s')\n", ofs.szPathName);
116}
#define OF_DELETE
Definition: winbase.h:127

◆ delete_fileW()

static void delete_fileW ( WCHAR fnameW)
static

Definition at line 511 of file lzexpand_main.c.

512{
513 INT file;
514 OFSTRUCT ofs;
515 DWORD retval;
516
517 file = LZOpenFileW(fnameW, &ofs, OF_DELETE);
518 ok(file >= 0, "LZOpenFileW failed on delete\n");
519 LZClose(file);
520 retval = GetFileAttributesW(fnameW);
521 ok(retval == INVALID_FILE_ATTRIBUTES, "GetFileAttributesW succeeded on deleted file ('%s')\n", ofs.szPathName);
522}

Referenced by test_LZOpenFileW_existing_compressed().

◆ full_file_path_name_in_a_CWD()

static void full_file_path_name_in_a_CWD ( const char src,
char dst,
BOOL  expect_short 
)
static

Definition at line 71 of file lzexpand_main.c.

72{
73 DWORD retval;
74 char shortname[MAX_PATH];
75
77 ok(retval > 0, "GetCurrentDirectoryA returned %d, GLE=%d\n",
78 retval, GetLastError());
79 if(dst[retval-1] != '\\')
80 /* Append backslash only when it's missing */
81 lstrcatA(dst, "\\");
83 if(expect_short)
84 {
85 memcpy(shortname, dst, MAX_PATH);
86 retval = GetShortPathNameA(shortname, dst, MAX_PATH-1);
87 ok(retval > 0, "GetShortPathNameA returned %d for '%s', GLE=%d\n",
88 retval, dst, GetLastError());
89 }
90}
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2146
DWORD WINAPI GetShortPathNameA(IN LPCSTR lpszLongPath, OUT LPSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1752
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by test_LZOpenFileA(), test_LZOpenFileA_existing_compressed(), test_LZOpenFileA_nonexisting_compressed(), test_LZOpenFileW(), test_LZOpenFileW_existing_compressed(), and test_LZOpenFileW_nonexisting_compressed().

◆ START_TEST()

START_TEST ( lzexpand_main  )

Definition at line 818 of file lzexpand_main.c.

819{
823 test_LZRead();
824 test_LZCopy();
826}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static void test_LZCopy(void)
static void test_LZRead(void)
static void test_LZOpenFileA(void)
static void test_LZOpenFileW(void)
static const DWORD uncompressed_data_size
Definition: lzexpand_main.c:67

◆ test_LZCopy()

static void test_LZCopy ( void  )
static

Definition at line 453 of file lzexpand_main.c.

454{
455 HANDLE file;
456 DWORD ret;
457 int source, dest;
458 OFSTRUCT stest, dtest;
459 BOOL retok;
460
461 /* Create the compressed file. */
464 "CreateFileA: error %d\n", GetLastError());
466 ok( retok, "WriteFile error %d\n", GetLastError());
467 ok(ret == compressed_file_size, "Wrote wrong number of bytes\n");
469
471 ok(source >= 0, "LZOpenFileA failed on compressed file\n");
473 ok(dest >= 0, "LZOpenFileA failed on creating new file %d\n", dest);
474
475 ret = LZCopy(source, dest);
476 ok(ret > 0, "LZCopy error\n");
477
479 LZClose(dest);
480
483 "CreateFileA: error %d\n", GetLastError());
484
485 retok = ReadFile(file, buf, uncompressed_data_size*2, &ret, 0);
486 ok( retok && ret == uncompressed_data_size, "ReadFile: error %d\n", GetLastError());
487 /* Compare what we read with what we think we should read. */
489 "buffer contents mismatch\n");
491
493 ok(ret, "DeleteFileA: error %d\n", GetLastError());
495 ok(ret, "DeleteFileA: error %d\n", GetLastError());
496}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG WINAPI LZCopy(HFILE src, HFILE dest)
Definition: lzexpand.c:467
static const DWORD compressed_file_size
Definition: lzexpand_main.c:64
static const char uncompressed_data[]
Definition: lzexpand_main.c:66
static const unsigned char compressed_file[]
Definition: lzexpand_main.c:59
static char filename2[]
Definition: lzexpand_main.c:51
static char filename_[]
Definition: lzexpand_main.c:32
#define CREATE_NEW
Definition: disk.h:69
static char * dest
Definition: rtl.c:135
#define GENERIC_WRITE
Definition: nt_native.h:90
int ret
#define OF_READ
Definition: winbase.h:117

Referenced by START_TEST().

◆ test_LZOpenFileA()

static void test_LZOpenFileA ( void  )
static

Definition at line 298 of file lzexpand_main.c.

299{
301 DWORD retval;
302 INT file;
303 static char badfilename_[] = "badfilename_";
304 char expected[MAX_PATH];
305 char short_expected[MAX_PATH];
306
307 SetLastError(0xfaceabee);
308 /* Check for nonexistent file. */
309 file = LZOpenFileA(badfilename_, &test, OF_READ);
311 "LZOpenFileA succeeded on nonexistent file\n");
313 "GetLastError() returns %d\n", GetLastError());
314 LZClose(file);
315
316 memset(&test, 0xA5, sizeof(test));
318
319 /* Create an empty file. */
321 ok(file >= 0, "LZOpenFileA failed on creation\n");
322 ok(test.cBytes == sizeof(OFSTRUCT),
323 "LZOpenFileA set test.cBytes to %d\n", test.cBytes);
324 ok(test.nErrCode == ERROR_SUCCESS,
325 "LZOpenFileA set test.nErrCode to %d\n", test.nErrCode);
326 ok(lstrcmpA(test.szPathName, expected) == 0,
327 "LZOpenFileA returned '%s', but was expected to return '%s'\n",
328 test.szPathName, expected);
329 LZClose(file);
330
332 ok(retval != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA: error %d\n",
333 GetLastError());
334
335 /* Check various opening options: */
336 memset(&test, 0xA5, sizeof(test));
338
339 /* a, for reading. */
341 ok(file >= 0, "LZOpenFileA failed on read\n");
342 ok(test.cBytes == sizeof(OFSTRUCT),
343 "LZOpenFileA set test.cBytes to %d '%s'('%s')\n", test.cBytes, expected, short_expected);
344 ok(test.nErrCode == ERROR_SUCCESS,
345 "LZOpenFileA set test.nErrCode to %d\n", test.nErrCode);
346 ok(lstrcmpA(test.szPathName, expected) == 0,
347 "LZOpenFileA returned '%s', but was expected to return '%s' or '%s'\n",
348 test.szPathName, expected, short_expected);
349 LZClose(file);
350
351 memset(&test, 0xA5, sizeof(test));
352
353 /* b, for writing. */
355 ok(file >= 0, "LZOpenFileA failed on write\n");
356 ok(test.cBytes == sizeof(OFSTRUCT),
357 "LZOpenFileA set test.cBytes to %d\n", test.cBytes);
358 ok(test.nErrCode == ERROR_SUCCESS,
359 "LZOpenFileA set test.nErrCode to %d\n", test.nErrCode);
360 ok(lstrcmpA(test.szPathName, expected) == 0,
361 "LZOpenFileA returned '%s', but was expected to return '%s' or '%s'\n",
362 test.szPathName, expected, short_expected);
363 LZClose(file);
364
365 memset(&test, 0xA5, sizeof(test));
366
367 /* c, for reading and writing. */
369 ok(file >= 0, "LZOpenFileA failed on read/write\n");
370 ok(test.cBytes == sizeof(OFSTRUCT),
371 "LZOpenFileA set test.cBytes to %d\n", test.cBytes);
372 ok(test.nErrCode == ERROR_SUCCESS,
373 "LZOpenFileA set test.nErrCode to %d\n", test.nErrCode);
374 ok(lstrcmpA(test.szPathName, expected) == 0,
375 "LZOpenFileA returned '%s', but was expected to return '%s' or '%s'\n",
376 test.szPathName, expected, short_expected);
377 LZClose(file);
378
379 memset(&test, 0xA5, sizeof(test));
380
381 /* d, for checking file existence. */
383 ok(file >= 0, "LZOpenFileA failed on read/write\n");
384 ok(test.cBytes == sizeof(OFSTRUCT),
385 "LZOpenFileA set test.cBytes to %d\n", test.cBytes);
386 ok(test.nErrCode == ERROR_SUCCESS,
387 "LZOpenFileA set test.nErrCode to %d\n", test.nErrCode);
388 ok(lstrcmpA(test.szPathName, expected) == 0,
389 "LZOpenFileA returned '%s', but was expected to return '%s' or '%s'\n",
390 test.szPathName, expected, short_expected);
391 LZClose(file);
392
393 memset(&test, 0xA5, sizeof(test));
394
395 /* Delete the file then make sure it doesn't exist anymore. */
397 ok(file >= 0, "LZOpenFileA failed on delete\n");
398 ok(test.cBytes == sizeof(OFSTRUCT),
399 "LZOpenFileA set test.cBytes to %d\n", test.cBytes);
400 ok(test.nErrCode == ERROR_SUCCESS,
401 "LZOpenFileA set test.nErrCode to %d\n", test.nErrCode);
402 ok(lstrcmpA(test.szPathName, expected) == 0,
403 "LZOpenFileA returned '%s', but was expected to return '%s' or '%s'\n",
404 test.szPathName, expected, short_expected);
405 LZClose(file);
406
408 ok(retval == INVALID_FILE_ATTRIBUTES,
409 "GetFileAttributesA succeeded on deleted file\n");
410
413}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:752
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4195
#define LZERROR_BADINHANDLE
Definition: lzexpand.h:7
static void test_LZOpenFileA_nonexisting_compressed(void)
static void test_LZOpenFileA_existing_compressed(void)
static void full_file_path_name_in_a_CWD(const char *src, char *dst, BOOL expect_short)
Definition: lzexpand_main.c:71
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
BOOL expected
Definition: store.c:2063
#define test
Definition: rosglue.h:37
#define memset(x, y, z)
Definition: compat.h:39
#define OF_EXIST
Definition: winbase.h:128
#define OF_READWRITE
Definition: winbase.h:118
#define OF_WRITE
Definition: winbase.h:119

Referenced by START_TEST().

◆ test_LZOpenFileA_existing_compressed()

static void test_LZOpenFileA_existing_compressed ( void  )
static

Definition at line 118 of file lzexpand_main.c.

119{
121 INT file;
122 char expected[MAX_PATH];
123 char short_expected[MAX_PATH];
124 char filled_0xA5[OFS_MAXPATHNAME];
125
126 /* Try to open existing compressed files: */
131
132 memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
133 memset(&test, 0xA5, sizeof(test));
135 SetLastError(0xfaceabee);
136
137 /* a, using 8.3-conformant file name. */
139 /* If the file "foo.xxx" does not exist, LZOpenFileA should then
140 check for the file "foo.xx_" and open that -- at least on some
141 operating systems. Doesn't seem to on my copy of Win98.
142 */
143 ok(file >= 0, "LZOpenFileA returns negative file descriptor for '%s'\n", filename);
144 ok(test.cBytes == sizeof(OFSTRUCT),
145 "LZOpenFileA set test.cBytes to %d\n", test.cBytes);
146 ok(test.nErrCode == 0, "LZOpenFileA set test.nErrCode to %d\n",
147 test.nErrCode);
148 ok(lstrcmpA(test.szPathName, expected) == 0,
149 "LZOpenFileA returned '%s', but was expected to return '%s'\n",
150 test.szPathName, expected);
151 LZClose(file);
152
153 memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
154 memset(&test, 0xA5, sizeof(test));
156 SetLastError(0xfaceabee);
157
158 /* b, using dotless file name. */
160 ok(file >= 0, "LZOpenFileA returns negative file descriptor for '%s'\n", dotless);
161 ok(test.cBytes == sizeof(OFSTRUCT),
162 "LZOpenFileA set test.cBytes to %d\n", test.cBytes);
163 ok(test.nErrCode == 0, "LZOpenFileA set test.nErrCode to %d\n",
164 test.nErrCode);
165 ok(lstrcmpA(test.szPathName, expected) == 0,
166 "LZOpenFileA returned '%s', but was expected to return '%s'\n",
167 test.szPathName, expected);
168 LZClose(file);
169
170 memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
171 memset(&test, 0xA5, sizeof(test));
173 SetLastError(0xfaceabee);
174
175 /* c, using extensionless file name. */
177 ok(file >= 0, "LZOpenFileA returns negative file descriptor for '%s'\n", extless);
178 ok(test.cBytes == sizeof(OFSTRUCT),
179 "LZOpenFileA set test.cBytes to %d\n", test.cBytes);
180 ok(test.nErrCode == 0, "LZOpenFileA set test.nErrCode to %d\n",
181 test.nErrCode);
182 ok(lstrcmpA(test.szPathName, expected) == 0,
183 "LZOpenFileA returned '%s', but was expected to return '%s'\n",
184 test.szPathName, expected);
185 LZClose(file);
186
187 memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
188 memset(&test, 0xA5, sizeof(test));
191
192 /* d, using underscore-terminated file name. */
194 ok(file >= 0, "LZOpenFileA failed on switching to a compressed file name\n");
195 ok(test.cBytes == sizeof(OFSTRUCT), "LZOpenFileA set test.cBytes to %d\n", test.cBytes);
196 ok(test.nErrCode == 0, "LZOpenFileA set test.nErrCode to %d\n",
197 test.nErrCode);
198 ok(lstrcmpA(test.szPathName, expected) == 0,
199 "LZOpenFileA returned '%s', but was expected to return '%s' or '%s'\n",
200 test.szPathName, expected, short_expected);
201 LZClose(file);
202
207}
const char * filename
Definition: ioapi.h:137
static char _terminated[]
Definition: lzexpand_main.c:46
static char extless[]
Definition: lzexpand_main.c:41
static char dotless_[]
Definition: lzexpand_main.c:37
static char dotless[]
Definition: lzexpand_main.c:36
static char extless_[]
Definition: lzexpand_main.c:42
static char _terminated_[]
Definition: lzexpand_main.c:47
#define create_file(name, size)
Definition: asmcache.c:813
#define delete_file(f)
Definition: reg_test.h:97
#define OFS_MAXPATHNAME
Definition: winbase.h:153

Referenced by test_LZOpenFileA().

◆ test_LZOpenFileA_nonexisting_compressed()

static void test_LZOpenFileA_nonexisting_compressed ( void  )
static

Definition at line 209 of file lzexpand_main.c.

210{
212 INT file;
213 char expected[MAX_PATH];
214 char filled_0xA5[OFS_MAXPATHNAME];
215
216 /* Try to open nonexisting compressed files: */
217 memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
218 memset(&test, 0xA5, sizeof(test));
220 SetLastError(0xfaceabee);
221
222 /* a, using 8.3-conformant file name. */
224 /* If the file "foo.xxx" does not exist, LZOpenFileA should then
225 check for the file "foo.xx_" and open that -- at least on some
226 operating systems. Doesn't seem to on my copy of Win98.
227 */
229 "LZOpenFileA succeeded on nonexistent file\n");
231 "GetLastError() returns %d\n", GetLastError());
232 ok(test.cBytes == 0xA5,
233 "LZOpenFileA set test.cBytes to %d\n", test.cBytes);
234 ok(test.nErrCode == ERROR_FILE_NOT_FOUND,
235 "LZOpenFileA set test.nErrCode to %d\n", test.nErrCode);
236 ok(lstrcmpA(test.szPathName, expected) == 0,
237 "LZOpenFileA returned '%s', but was expected to return '%s' or '%s'\n",
238 test.szPathName, expected, filled_0xA5);
239
240 memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
241 memset(&test, 0xA5, sizeof(test));
243 SetLastError(0xfaceabee);
244
245 /* b, using dotless file name. */
248 "LZOpenFileA succeeded on nonexistent file\n");
250 "GetLastError() returns %d\n", GetLastError());
251 ok(test.cBytes == 0xA5,
252 "LZOpenFileA set test.cBytes to %d\n", test.cBytes);
253 ok(test.nErrCode == ERROR_FILE_NOT_FOUND,
254 "LZOpenFileA set test.nErrCode to %d\n", test.nErrCode);
255 ok(lstrcmpA(test.szPathName, expected) == 0,
256 "LZOpenFileA returned '%s', but was expected to return '%s' or '%s'\n",
257 test.szPathName, expected, filled_0xA5);
258
259 memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
260 memset(&test, 0xA5, sizeof(test));
262 SetLastError(0xfaceabee);
263
264 /* c, using extensionless file name. */
267 "LZOpenFileA succeeded on nonexistent file\n");
269 "GetLastError() returns %d\n", GetLastError());
270 ok(test.cBytes == 0xA5,
271 "LZOpenFileA set test.cBytes to %d\n", test.cBytes);
272 ok(test.nErrCode == ERROR_FILE_NOT_FOUND,
273 "LZOpenFileA set test.nErrCode to %d\n", test.nErrCode);
274 ok(lstrcmpA(test.szPathName, expected) == 0,
275 "LZOpenFileA returned '%s', but was expected to return '%s' or '%s'\n",
276 test.szPathName, expected, filled_0xA5);
277
278 memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
279 memset(&test, 0xA5, sizeof(test));
281 SetLastError(0xfaceabee);
282
283 /* d, using underscore-terminated file name. */
286 "LZOpenFileA succeeded on nonexistent file\n");
288 "GetLastError() returns %d\n", GetLastError());
289 ok(test.cBytes == 0xA5,
290 "LZOpenFileA set test.cBytes to %d\n", test.cBytes);
291 ok(test.nErrCode == ERROR_FILE_NOT_FOUND,
292 "LZOpenFileA set test.nErrCode to %d\n", test.nErrCode);
293 ok(lstrcmpA(test.szPathName, expected) == 0,
294 "LZOpenFileA returned '%s', but was expected to return '%s' or '%s'\n",
295 test.szPathName, expected, filled_0xA5);
296}

Referenced by test_LZOpenFileA().

◆ test_LZOpenFileW()

static void test_LZOpenFileW ( void  )
static

Definition at line 698 of file lzexpand_main.c.

699{
701 DWORD retval;
702 INT file;
703 static WCHAR badfilenameW[] = {'b','a','d','f','i','l','e','n','a','m','e','.','x','t','n',0};
704 char expected[MAX_PATH];
705
706 SetLastError(0xfaceabee);
707 /* Check for nonexistent file. */
708 file = LZOpenFileW(badfilenameW, &test, OF_READ);
710 {
711 win_skip("LZOpenFileW call is not implemented\n");
712 return;
713 }
715 "GetLastError() returns %d\n", GetLastError());
716 ok(file == LZERROR_BADINHANDLE, "LZOpenFileW succeeded on nonexistent file\n");
717 LZClose(file);
718
719 memset(&test, 0xA5, sizeof(test));
721
722 /* Create an empty file. */
724 ok(file >= 0, "LZOpenFile failed on creation\n");
725 ok(test.cBytes == sizeof(OFSTRUCT),
726 "LZOpenFileW set test.cBytes to %d\n", test.cBytes);
727 ok(test.nErrCode == ERROR_SUCCESS,
728 "LZOpenFileW set test.nErrCode to %d\n", test.nErrCode);
729 ok(lstrcmpA(test.szPathName, expected) == 0,
730 "LZOpenFileW returned '%s', but was expected to return '%s'\n",
731 test.szPathName, expected);
732 LZClose(file);
733
735 ok(retval != INVALID_FILE_ATTRIBUTES, "GetFileAttributes: error %d\n",
736 GetLastError());
737
738 /* Check various opening options: */
739 memset(&test, 0xA5, sizeof(test));
740
741 /* a, for reading. */
743 ok(file >= 0, "LZOpenFileW failed on read\n");
744 ok(test.cBytes == sizeof(OFSTRUCT),
745 "LZOpenFileW set test.cBytes to %d\n", test.cBytes);
746 ok(test.nErrCode == ERROR_SUCCESS,
747 "LZOpenFileW set test.nErrCode to %d\n", test.nErrCode);
748 ok(lstrcmpA(test.szPathName, expected) == 0,
749 "LZOpenFileW returned '%s', but was expected to return '%s'\n",
750 test.szPathName, expected);
751 LZClose(file);
752
753 memset(&test, 0xA5, sizeof(test));
754
755 /* b, for writing. */
757 ok(file >= 0, "LZOpenFileW failed on write\n");
758 ok(test.cBytes == sizeof(OFSTRUCT),
759 "LZOpenFileW set test.cBytes to %d\n", test.cBytes);
760 ok(test.nErrCode == ERROR_SUCCESS,
761 "LZOpenFileW set test.nErrCode to %d\n", test.nErrCode);
762 ok(lstrcmpA(test.szPathName, expected) == 0,
763 "LZOpenFileW returned '%s', but was expected to return '%s'\n",
764 test.szPathName, expected);
765 LZClose(file);
766
767 memset(&test, 0xA5, sizeof(test));
768
769 /* c, for reading and writing. */
771 ok(file >= 0, "LZOpenFileW failed on read/write\n");
772 ok(test.cBytes == sizeof(OFSTRUCT),
773 "LZOpenFileW set test.cBytes to %d\n", test.cBytes);
774 ok(test.nErrCode == ERROR_SUCCESS,
775 "LZOpenFileW set test.nErrCode to %d\n", test.nErrCode);
776 ok(lstrcmpA(test.szPathName, expected) == 0,
777 "LZOpenFileW returned '%s', but was expected to return '%s'\n",
778 test.szPathName, expected);
779 LZClose(file);
780
781 memset(&test, 0xA5, sizeof(test));
782
783 /* d, for checking file existence. */
785 ok(file >= 0, "LZOpenFileW failed on read/write\n");
786 ok(test.cBytes == sizeof(OFSTRUCT),
787 "LZOpenFileW set test.cBytes to %d\n", test.cBytes);
788 ok(test.nErrCode == ERROR_SUCCESS,
789 "LZOpenFileW set test.nErrCode to %d\n", test.nErrCode);
790 ok(lstrcmpA(test.szPathName, expected) == 0,
791 "LZOpenFileW returned '%s', but was expected to return '%s'\n",
792 test.szPathName, expected);
793 LZClose(file);
794
795 memset(&test, 0xA5, sizeof(test));
796
797 /* Delete the file then make sure it doesn't exist anymore. */
799 ok(file >= 0, "LZOpenFileW failed on delete\n");
800 ok(test.cBytes == sizeof(OFSTRUCT),
801 "LZOpenFileW set test.cBytes to %d\n", test.cBytes);
802 ok(test.nErrCode == ERROR_SUCCESS,
803 "LZOpenFileW set test.nErrCode to %d\n", test.nErrCode);
804 ok(lstrcmpA(test.szPathName, expected) == 0,
805 "LZOpenFileW returned '%s', but was expected to return '%s'\n",
806 test.szPathName, expected);
807 LZClose(file);
808
810 ok(retval == INVALID_FILE_ATTRIBUTES,
811 "GetFileAttributesW succeeded on deleted file\n");
812
815}
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
static void test_LZOpenFileW_nonexisting_compressed(void)
static void test_LZOpenFileW_existing_compressed(void)
static WCHAR filenameW_[]
Definition: lzexpand_main.c:34
#define win_skip
Definition: test.h:163
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_LZOpenFileW_existing_compressed()

static void test_LZOpenFileW_existing_compressed ( void  )
static

Definition at line 524 of file lzexpand_main.c.

525{
527 INT file;
528 char expected[MAX_PATH];
529
530 /* Try to open existing compressed files: */
535
537 memset(&test, 0xA5, sizeof(test));
538
539 /* a, using 8.3-conformant file name. */
541 /* If the file "foo.xxx" does not exist, LZOpenFileW should then
542 check for the file "foo.xx_" and open that.
543 */
544 ok(file >= 0, "LZOpenFileW failed on switching to a compressed file name\n");
545 ok(test.cBytes == sizeof(OFSTRUCT),
546 "LZOpenFileW set test.cBytes to %d\n", test.cBytes);
547 ok(test.nErrCode == ERROR_SUCCESS, "LZOpenFileW set test.nErrCode to %d\n",
548 test.nErrCode);
549 /* Note that W-function returns A-string by a OFSTRUCT.szPathName: */
550 ok(lstrcmpA(test.szPathName, expected) == 0,
551 "LZOpenFileW returned '%s', but was expected to return '%s'\n",
552 test.szPathName, expected);
553 LZClose(file);
554
555 memset(&test, 0xA5, sizeof(test));
557
558 /* b, using dotless file name. */
560 ok(file >= 0, "LZOpenFileW failed on switching to a compressed file name\n");
561 ok(test.cBytes == sizeof(OFSTRUCT),
562 "LZOpenFileW set test.cBytes to %d\n", test.cBytes);
563 ok(test.nErrCode == ERROR_SUCCESS, "LZOpenFileW set test.nErrCode to %d\n",
564 test.nErrCode);
565 /* Note that W-function returns A-string by a OFSTRUCT.szPathName: */
566 ok(lstrcmpA(test.szPathName, expected) == 0,
567 "LZOpenFileW returned '%s', but was expected to return '%s'\n",
568 test.szPathName, expected);
569 LZClose(file);
570
571 memset(&test, 0xA5, sizeof(test));
573
574 /* c, using extensionless file name. */
576 ok(file >= 0, "LZOpenFileW failed on switching to a compressed file name\n");
577 ok(test.cBytes == sizeof(OFSTRUCT),
578 "LZOpenFileW set test.cBytes to %d\n", test.cBytes);
579 ok(test.nErrCode == ERROR_SUCCESS, "LZOpenFileW set test.nErrCode to %d\n",
580 test.nErrCode);
581 /* Note that W-function returns A-string by a OFSTRUCT.szPathName: */
582 ok(lstrcmpA(test.szPathName, expected) == 0,
583 "LZOpenFileW returned '%s', but was expected to return '%s'\n",
584 test.szPathName, expected);
585 LZClose(file);
586
587 memset(&test, 0xA5, sizeof(test));
589
590 /* d, using underscore-terminated file name. */
592 ok(file >= 0, "LZOpenFileW failed on switching to a compressed file name\n");
593 ok(test.cBytes == sizeof(OFSTRUCT),
594 "LZOpenFileW set test.cBytes to %d\n", test.cBytes);
595 ok(test.nErrCode == ERROR_SUCCESS, "LZOpenFileW set test.nErrCode to %d\n",
596 test.nErrCode);
597 /* Note that W-function returns A-string by a OFSTRUCT.szPathName: */
598 ok(lstrcmpA(test.szPathName, expected) == 0,
599 "LZOpenFileW returned '%s', but was expected to return '%s'\n",
600 test.szPathName, expected);
601 LZClose(file);
602
607}
static WCHAR filenameW[]
Definition: lzexpand_main.c:33
static WCHAR extlessW_[]
Definition: lzexpand_main.c:44
static WCHAR _terminatedW_[]
Definition: lzexpand_main.c:49
static WCHAR dotlessW_[]
Definition: lzexpand_main.c:39
static void delete_fileW(WCHAR *fnameW)
static WCHAR extlessW[]
Definition: lzexpand_main.c:43
static WCHAR _terminatedW[]
Definition: lzexpand_main.c:48
static WCHAR dotlessW[]
Definition: lzexpand_main.c:38
static void create_fileW(WCHAR *fnameW)

Referenced by test_LZOpenFileW().

◆ test_LZOpenFileW_nonexisting_compressed()

static void test_LZOpenFileW_nonexisting_compressed ( void  )
static

Definition at line 609 of file lzexpand_main.c.

610{
612 INT file;
613 char expected[MAX_PATH];
614 char filled_0xA5[OFS_MAXPATHNAME];
615
616 /* Try to open nonexisting compressed files: */
617 memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
618 memset(&test, 0xA5, sizeof(test));
620 SetLastError(0xfaceabee);
621
622 /* a, using 8.3-conformant file name. */
624 /* If the file "foo.xxx" does not exist, LZOpenFileA should then
625 check for the file "foo.xx_" and open that -- at least on some
626 operating systems. Doesn't seem to on my copy of Win98.
627 */
629 "LZOpenFileW succeeded on nonexistent file\n");
631 "GetLastError() returns %d\n", GetLastError());
632 ok(test.cBytes == 0xA5,
633 "LZOpenFileW set test.cBytes to %d\n", test.cBytes);
634 ok(test.nErrCode == ERROR_FILE_NOT_FOUND,
635 "LZOpenFileW set test.nErrCode to %d\n", test.nErrCode);
636 ok(lstrcmpA(test.szPathName, expected) == 0,
637 "LZOpenFileW returned '%s', but was expected to return '%s' or '%s'\n",
638 test.szPathName, expected, filled_0xA5);
639
640 memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
641 memset(&test, 0xA5, sizeof(test));
643 SetLastError(0xfaceabee);
644
645 /* b, using dotless file name. */
648 "LZOpenFileW succeeded on nonexistent file\n");
650 "GetLastError() returns %d\n", GetLastError());
651 ok(test.cBytes == 0xA5,
652 "LZOpenFileW set test.cBytes to %d\n", test.cBytes);
653 ok(test.nErrCode == ERROR_FILE_NOT_FOUND,
654 "LZOpenFileW set test.nErrCode to %d\n", test.nErrCode);
655 ok(lstrcmpA(test.szPathName, expected) == 0,
656 "LZOpenFileW returned '%s', but was expected to return '%s' or '%s'\n",
657 test.szPathName, expected, filled_0xA5);
658
659 memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
660 memset(&test, 0xA5, sizeof(test));
662 SetLastError(0xfaceabee);
663
664 /* c, using extensionless file name. */
667 "LZOpenFileW succeeded on nonexistent file\n");
669 "GetLastError() returns %d\n", GetLastError());
670 ok(test.cBytes == 0xA5,
671 "LZOpenFileW set test.cBytes to %d\n", test.cBytes);
672 ok(test.nErrCode == ERROR_FILE_NOT_FOUND,
673 "LZOpenFileW set test.nErrCode to %d\n", test.nErrCode);
674 ok(lstrcmpA(test.szPathName, expected) == 0,
675 "LZOpenFileW returned '%s', but was expected to return '%s' or '%s'\n",
676 test.szPathName, expected, filled_0xA5);
677
678 memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
679 memset(&test, 0xA5, sizeof(test));
681 SetLastError(0xfaceabee);
682
683 /* d, using underscore-terminated file name. */
686 "LZOpenFileW succeeded on nonexistent file\n");
688 "GetLastError() returns %d\n", GetLastError());
689 ok(test.cBytes == 0xA5,
690 "LZOpenFileW set test.cBytes to %d\n", test.cBytes);
691 ok(test.nErrCode == ERROR_FILE_NOT_FOUND,
692 "LZOpenFileW set test.nErrCode to %d\n", test.nErrCode);
693 ok(lstrcmpA(test.szPathName, expected) == 0,
694 "LZOpenFileW returned '%s', but was expected to return '%s' or '%s'\n",
695 test.szPathName, expected, filled_0xA5);
696}

Referenced by test_LZOpenFileW().

◆ test_LZRead()

static void test_LZRead ( void  )
static

Definition at line 415 of file lzexpand_main.c.

416{
417 HANDLE file;
418 DWORD ret;
419 int cfile;
421 BOOL retok;
422
423 /* Create the compressed file. */
425 ok(file != INVALID_HANDLE_VALUE, "Could not create test file\n");
427 ok( retok, "WriteFile: error %d\n", GetLastError());
428 ok(ret == compressed_file_size, "Wrote wrong number of bytes with WriteFile?\n");
430
432 ok(cfile > 0, "LZOpenFileA failed\n");
433
435 ok(ret == uncompressed_data_size, "Read wrong number of bytes\n");
436
437 /* Compare what we read with what we think we should read. */
439 "buffer contents mismatch\n");
440
441 todo_wine {
442 /* Wine returns the number of bytes actually read instead of an error */
444 ok(ret == LZERROR_READ, "Expected read-past-EOF to return LZERROR_READ\n");
445 }
446
447 LZClose(cfile);
448
450 ok(ret, "DeleteFileA: error %d\n", GetLastError());
451}
INT WINAPI LZRead(HFILE fd, LPSTR vbuf, INT toread)
Definition: lzexpand.c:345
#define LZERROR_READ
Definition: lzexpand.h:9
#define todo_wine
Definition: custom.c:89
static FILE * cfile
Definition: ruserpass.c:25

Referenced by START_TEST().

Variable Documentation

◆ _terminated

char _terminated[] = "_terminated.xxxx_"
static

◆ _terminated_

◆ _terminatedW

WCHAR _terminatedW[] = {'_','t','e','r','m','i','n','a','t','e','d','.','x','x','x','x','_', 0}
static

◆ _terminatedW_

WCHAR _terminatedW_[] = {'_','t','e','r','m','i','n','a','t','e','d','.','x','x','x','x','_', 0}
static

Definition at line 49 of file lzexpand_main.c.

Referenced by test_LZOpenFileW_existing_compressed().

◆ buf

char* buf
static

Definition at line 69 of file lzexpand_main.c.

◆ compressed_file

const unsigned char compressed_file[]
static
Initial value:
=
{0x53,0x5A,0x44,0x44,0x88,0xF0,0x27,0x33,0x41,
0x74,0x75,0x14,0x00,0x00,0xDF,0x54,0x68,0x69,
0x73,0x20,0xF2,0xF0,0x61,0x20,0xFF,0x74,0x65,
0x73,0x74,0x20,0x66,0x69,0x6C,0x03,0x65,0x2E}

Definition at line 59 of file lzexpand_main.c.

Referenced by test_LZCopy(), and test_LZRead().

◆ compressed_file_size

const DWORD compressed_file_size = sizeof(compressed_file)
static

Definition at line 64 of file lzexpand_main.c.

Referenced by test_LZCopy(), and test_LZRead().

◆ dotless

char dotless[] = "dotless"
static

◆ dotless_

◆ dotlessW

WCHAR dotlessW[] = {'d','o','t','l','e','s','s', 0}
static

◆ dotlessW_

WCHAR dotlessW_[] = {'d','o','t','l','e','s','s','.','_', 0}
static

Definition at line 39 of file lzexpand_main.c.

Referenced by test_LZOpenFileW_existing_compressed().

◆ extless

char extless[] = "extless."
static

◆ extless_

◆ extlessW

WCHAR extlessW[] = {'e','x','t','l','e','s','s','.', 0}
static

◆ extlessW_

WCHAR extlessW_[] = {'e','x','t','l','e','s','s','.','_', 0}
static

Definition at line 44 of file lzexpand_main.c.

Referenced by test_LZOpenFileW_existing_compressed().

◆ filename

char filename[] = "testfile.xxx"
static

Definition at line 31 of file lzexpand_main.c.

◆ filename2

char filename2[] = "testfile.yyy"
static

◆ filename_

◆ filenameW

WCHAR filenameW[] = {'t','e','s','t','f','i','l','e','.','x','x','x',0}
static

◆ filenameW_

WCHAR filenameW_[] = {'t','e','s','t','f','i','l','e','.','x','x','_',0}
static

Definition at line 34 of file lzexpand_main.c.

Referenced by test_LZOpenFileW(), and test_LZOpenFileW_existing_compressed().

◆ uncompressed_data

const char uncompressed_data[] = "This is a test file."
static

Definition at line 66 of file lzexpand_main.c.

Referenced by test_LZCopy(), and test_LZRead().

◆ uncompressed_data_size

const DWORD uncompressed_data_size = sizeof(uncompressed_data) - 1
static

Definition at line 67 of file lzexpand_main.c.

Referenced by START_TEST(), test_LZCopy(), and test_LZRead().