diff --git a/configure b/configure index 6f7d0b2b60b..448ce28921c 100755 --- a/configure +++ b/configure @@ -20240,7 +20240,7 @@ MAKE_LIB_RULES=libs/Makelib.rules MAKE_PROG_RULES=programs/Makeprog.rules - ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/advpack/Makefile dlls/amstream/Makefile dlls/atl/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/capi2032/Makefile dlls/cards/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/ctl3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3dim/Makefile dlls/d3drm/Makefile dlls/d3dx8/Makefile dlls/d3dxof/Makefile dlls/dbghelp/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnet/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/dxdiagn/Makefile dlls/dxerr8/Makefile dlls/dxerr9/Makefile dlls/dxguid/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/hhctrl.ocx/Makefile dlls/iccvid/Makefile dlls/icmp/Makefile dlls/ifsmgr.vxd/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/itss/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mapi32/tests/Makefile dlls/mlang/Makefile dlls/mlang/tests/Makefile dlls/mmdevldr.vxd/Makefile dlls/monodebg.vxd/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msacm/tests/Makefile dlls/mscms/Makefile dlls/mscms/tests/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/msi/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile dlls/msvcrtd/Makefile dlls/msvcrtd/tests/Makefile dlls/msvidc32/Makefile dlls/msvideo/Makefile dlls/mswsock/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/ole32/tests/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/psapi/tests/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/quartz/tests/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/rsabase/Makefile dlls/rsabase/tests/Makefile dlls/rsaenh/Makefile dlls/rsaenh/tests/Makefile dlls/secur32/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/sti/Makefile dlls/strmiids/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/uuid/Makefile dlls/uxtheme/Makefile dlls/vdhcp.vxd/Makefile dlls/vdmdbg/Makefile dlls/version/Makefile dlls/version/tests/Makefile dlls/vmm.vxd/Makefile dlls/vnbt.vxd/Makefile dlls/vnetbios.vxd/Makefile dlls/vtdapi.vxd/Makefile dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winejack/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile fonts/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/msiexec/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/taskmgr/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile" + ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/advpack/Makefile dlls/amstream/Makefile dlls/atl/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/capi2032/Makefile dlls/cards/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/ctl3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3dim/Makefile dlls/d3drm/Makefile dlls/d3dx8/Makefile dlls/d3dxof/Makefile dlls/dbghelp/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnet/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/dxdiagn/Makefile dlls/dxerr8/Makefile dlls/dxerr9/Makefile dlls/dxguid/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/hhctrl.ocx/Makefile dlls/iccvid/Makefile dlls/icmp/Makefile dlls/ifsmgr.vxd/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/itss/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/lzexpand/tests/Makefile dlls/mapi32/Makefile dlls/mapi32/tests/Makefile dlls/mlang/Makefile dlls/mlang/tests/Makefile dlls/mmdevldr.vxd/Makefile dlls/monodebg.vxd/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msacm/tests/Makefile dlls/mscms/Makefile dlls/mscms/tests/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/msi/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile dlls/msvcrtd/Makefile dlls/msvcrtd/tests/Makefile dlls/msvidc32/Makefile dlls/msvideo/Makefile dlls/mswsock/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/ole32/tests/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/psapi/tests/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/quartz/tests/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/rsabase/Makefile dlls/rsabase/tests/Makefile dlls/rsaenh/Makefile dlls/rsaenh/tests/Makefile dlls/secur32/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/sti/Makefile dlls/strmiids/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/uuid/Makefile dlls/uxtheme/Makefile dlls/vdhcp.vxd/Makefile dlls/vdmdbg/Makefile dlls/version/Makefile dlls/version/tests/Makefile dlls/vmm.vxd/Makefile dlls/vnbt.vxd/Makefile dlls/vnetbios.vxd/Makefile dlls/vtdapi.vxd/Makefile dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winejack/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile fonts/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/msiexec/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/taskmgr/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile" cat >confcache <<\_ACEOF @@ -20845,6 +20845,7 @@ do "dlls/kernel/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/kernel/Makefile" ;; "dlls/kernel/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/kernel/tests/Makefile" ;; "dlls/lzexpand/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/lzexpand/Makefile" ;; + "dlls/lzexpand/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/lzexpand/tests/Makefile" ;; "dlls/mapi32/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/mapi32/Makefile" ;; "dlls/mapi32/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/mapi32/tests/Makefile" ;; "dlls/mlang/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/mlang/Makefile" ;; diff --git a/configure.ac b/configure.ac index 4175e358a74..cfbd5fa3093 100644 --- a/configure.ac +++ b/configure.ac @@ -1636,6 +1636,7 @@ dlls/itss/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile +dlls/lzexpand/tests/Makefile dlls/mapi32/Makefile dlls/mapi32/tests/Makefile dlls/mlang/Makefile diff --git a/dlls/lzexpand/Makefile.in b/dlls/lzexpand/Makefile.in index c942e158c3a..65642c6f63c 100644 --- a/dlls/lzexpand/Makefile.in +++ b/dlls/lzexpand/Makefile.in @@ -10,6 +10,8 @@ C_SRCS = lzexpand_main.c C_SRCS16 = lzexpand16.c SPEC_SRCS16 = lzexpand.spec +SUBDIRS = tests + @MAKE_DLL_RULES@ ### Dependencies: diff --git a/dlls/lzexpand/tests/.cvsignore b/dlls/lzexpand/tests/.cvsignore new file mode 100644 index 00000000000..9932b8a14f6 --- /dev/null +++ b/dlls/lzexpand/tests/.cvsignore @@ -0,0 +1,3 @@ +Makefile +lzexpand_main.ok +testlist.c diff --git a/dlls/lzexpand/tests/Makefile.in b/dlls/lzexpand/tests/Makefile.in new file mode 100644 index 00000000000..b098fa2d2fd --- /dev/null +++ b/dlls/lzexpand/tests/Makefile.in @@ -0,0 +1,13 @@ +TOPSRCDIR = @top_srcdir@ +TOPOBJDIR = ../../.. +SRCDIR = @srcdir@ +VPATH = @srcdir@ +TESTDLL = lz32.dll +IMPORTS = lz32 + +CTESTS = \ + lzexpand_main.c + +@MAKE_TEST_RULES@ + +### Dependencies: diff --git a/dlls/lzexpand/tests/lzexpand_main.c b/dlls/lzexpand/tests/lzexpand_main.c new file mode 100644 index 00000000000..a8d3559632e --- /dev/null +++ b/dlls/lzexpand/tests/lzexpand_main.c @@ -0,0 +1,226 @@ +/* + * Unit test suite for lz32 functions + * + * Copyright 2004 Evan Parry, Daniel Kegel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include + +#ifndef STANDALONE +#include "wine/test.h" +#define ok2 ok +#else +/* To build outside Wine tree, compile with cl -DSTANDALONE -D_X86_ lzexpand_main.c lz32.lib */ +#include +#include +#define START_TEST(name) main(int argc, char **argv) +#define ok(condition, msg) \ + do { if(!(condition)) { \ + fprintf(stderr,"failed at %d, msg:" msg "\n",__LINE__); \ + exit(1); \ + } } while(0) +#define ok2(condition, msg, arg) \ + do { if(!(condition)) { \ + fprintf(stderr,"failed at %d, msg:" msg "\n",__LINE__, arg); \ + exit(1); \ + } } while(0) +#define todo_wine +#endif + +#include +#include + +static char* filename_ = "testfile.xx_"; +#if 0 +static char* filename = "testfile.xxx"; +#endif +static char* filename2 = "testfile.yyy"; + +/* This is the hex string representation of the file created by compressing + a simple text file with the contents "This is a test file." + + The file was created using COMPRESS.EXE from the Windows Server 2003 + Resource Kit from Microsoft. The resource kit was retrieved from the + following URL: + + http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en + */ +static const unsigned char compressed_file[] = + {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}; +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 char *buf; + +static void test_lzopenfile(void) +{ + OFSTRUCT test; + DWORD retval; + INT file; + + /* Check for non-existent file. */ + file = LZOpenFile("badfilename_", &test, OF_READ); + ok(file == LZERROR_BADINHANDLE, + "LZOpenFile succeeded on nonexistent file\n"); + LZClose(file); + + /* Create an empty file. */ + file = LZOpenFile(filename_, &test, OF_CREATE); + ok(file >= 0, "LZOpenFile failed on creation\n"); + LZClose(file); + retval = GetFileAttributes(filename_); + ok2(retval != INVALID_FILE_ATTRIBUTES, "GetFileAttributes: error %ld\n", + GetLastError()); + + /* Check various opening options. */ + file = LZOpenFile(filename_, &test, OF_READ); + ok(file >= 0, "LZOpenFile failed on read\n"); + LZClose(file); + file = LZOpenFile(filename_, &test, OF_WRITE); + ok(file >= 0, "LZOpenFile failed on write\n"); + LZClose(file); + file = LZOpenFile(filename_, &test, OF_READWRITE); + ok(file >= 0, "LZOpenFile failed on read/write\n"); + LZClose(file); + file = LZOpenFile(filename_, &test, OF_EXIST); + ok(file >= 0, "LZOpenFile failed on read/write\n"); + LZClose(file); + + + /* If the file "foo.xxx" does not exist, LZOpenFile should then + check for the file "foo.xx_" and open that -- at least on some + operating systems. Doesn't seem to on my copy of Win98. + The Wine testing guidelines say we should accept the behavior of + any valid version of Windows. Thus it seems we cannot check this?! + Revisit this at some point to see if this can be tested somehow. + */ +#if 0 + file = LZOpenFile(filename, &test, OF_EXIST); + ok(file != LZERROR_BADINHANDLE, + "LZOpenFile \"filename_\" check failed\n"); + LZClose(file); +#endif + + /* Delete the file then make sure it doesn't exist anymore. */ + file = LZOpenFile(filename_, &test, OF_DELETE); + ok(file >= 0, "LZOpenFile failed on delete\n"); + LZClose(file); + + retval = GetFileAttributes(filename_); + ok(retval == INVALID_FILE_ATTRIBUTES, + "GetFileAttributes succeeded on deleted file\n"); + +} + +static void test_lzread(void) +{ + HANDLE file; + DWORD ret; + int cfile; + OFSTRUCT test; + + /* Create the compressed file. */ + file = CreateFile(filename_, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, 0); + ok(file != INVALID_HANDLE_VALUE, "Could not create test file\n"); + ok2(WriteFile(file, compressed_file, compressed_file_size, &ret, 0), + "WriteFile: error %ld\n", GetLastError()); + ok(ret == compressed_file_size, "Wrote wrong number of bytes with WriteFile?\n"); + CloseHandle(file); + + cfile = LZOpenFile(filename_, &test, OF_READ); + ok(cfile > 0, "LZOpenFile failed\n"); + + ret = LZRead(cfile, buf, uncompressed_data_size); + ok(ret == uncompressed_data_size, "Read wrong number of bytes\n"); + + /* Compare what we read with what we think we should read. */ + ok(memcmp(buf, uncompressed_data, uncompressed_data_size) == 0, + "buffer contents mismatch\n"); + + todo_wine { + /* Wine returns the number of bytes actually read instead of an error */ + ret = LZRead(cfile, buf, uncompressed_data_size); + ok(ret == LZERROR_READ, "Expected read-past-EOF to return LZERROR_READ\n"); + } + + LZClose(cfile); + + ret = DeleteFile(filename_); + ok2(ret, "DeleteFile: error %ld\n", GetLastError()); +} + +static void test_lzcopy(void) +{ + HANDLE file; + DWORD ret; + int source, dest; + OFSTRUCT stest, dtest; + + /* Create the compressed file. */ + file = CreateFile(filename_, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, 0); + ok2(file != INVALID_HANDLE_VALUE, + "CreateFile: error %ld\n", GetLastError()); + ok2(WriteFile(file, compressed_file, compressed_file_size, &ret, 0), + "WriteFile error %ld\n", GetLastError()); + ok(ret == compressed_file_size, "Wrote wrong number of bytes\n"); + CloseHandle(file); + + source = LZOpenFile(filename_, &stest, OF_READ); + ok(source >= 0, "LZOpenFile failed on compressed file\n"); + dest = LZOpenFile(filename2, &dtest, OF_CREATE); + ok2(dest >= 0, "LZOpenFile failed on creating new file %d\n", dest); + + ret = LZCopy(source, dest); + ok(ret > 0, "LZCopy error\n"); + + LZClose(source); + LZClose(dest); + + file = CreateFile(filename2, GENERIC_READ, 0, NULL, OPEN_EXISTING, + 0, 0); + ok2(file != INVALID_HANDLE_VALUE, + "CreateFile: error %ld\n", GetLastError()); + + ok2(ReadFile(file, buf, uncompressed_data_size*2, &ret, 0) && + ret == uncompressed_data_size, "ReadFile: error %ld\n", GetLastError()); + /* Compare what we read with what we think we should read. */ + ok(!memcmp(buf, uncompressed_data, uncompressed_data_size), + "buffer contents mismatch\n"); + CloseHandle(file); + + ret = DeleteFile(filename_); + ok2(ret, "DeleteFile: error %ld\n", GetLastError()); + ret = DeleteFile(filename2); + ok2(ret, "DeleteFile: error %ld\n", GetLastError()); +} + +START_TEST(lzexpand_main) +{ + buf = malloc(uncompressed_data_size * 2); + test_lzopenfile(); + test_lzread(); + test_lzcopy(); + free(buf); +}