Changelog dlls/msvcrt/test/file.c: test_fileops Do some tests around fget(w)s -- Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt --------- Tel. 06151 162516 -------- Fax. 06151 164321 ---------- Index: wine/dlls/msvcrt/tests/file.c =================================================================== RCS file: /home/wine/wine/dlls/msvcrt/tests/file.c,v retrieving revision 1.4 diff -u -r1.4 file.c --- wine/dlls/msvcrt/tests/file.c 5 Sep 2003 23:08:35 -0000 1.4 +++ wine/dlls/msvcrt/tests/file.c 5 Oct 2003 10:44:10 -0000 @@ -46,8 +46,50 @@ ok (memcmp (buffer, buffer + 5, 5) == 0, "read wrong bytes"); fclose (file); unlink ("fdopen.tst"); + close (fd); } +static void test_fileops( void ) +{ + static char outbuffer[] = "0,1,2,3,4,5,6,7,8,9"; + char buffer[256]; + WCHAR wbuffer[256]; + int fd; + FILE *file; + + fd = open ("fdopen.tst", O_WRONLY | O_CREAT | O_BINARY, _S_IREAD |_S_IWRITE); + write (fd, outbuffer, sizeof (outbuffer)); + close (fd); + + fd = open ("fdopen.tst", O_RDONLY | O_BINARY); + file = fdopen (fd, "rb"); + ok(strlen(outbuffer) == (sizeof(outbuffer)-1),"strlen/sizeof error"); + ok(fgets(buffer,sizeof(buffer),file) !=0,"fgets failed unexpected"); + ok(fgets(buffer,sizeof(buffer),file) ==0,"fgets didn't signal EOF"); + ok(feof(file) !=0,"feof doesn't signal EOF"); + rewind(file); + ok(fgets(buffer,strlen(outbuffer),file) !=0,"fgets failed unexpected"); + ok(lstrlenA(buffer) == strlen(outbuffer) -1,"fgets didn't read right size"); + ok(fgets(buffer,sizeof(outbuffer),file) !=0,"fgets failed unexpected"); + ok(strlen(buffer) == 1,"fgets dropped chars"); + ok(buffer[0] == outbuffer[strlen(outbuffer)-1],"fgets exchanged chars"); + fclose (file); + close (fd); + fd = open ("fdopen.tst", O_RDONLY | O_TEXT); + file = fdopen (fd, "rt"); /* open in TEXT mode */ + ok(fgetws(wbuffer,sizeof(wbuffer),file) !=0,"fgetws failed unexpected"); + ok(fgetws(wbuffer,sizeof(wbuffer),file) ==0,"fgetws didn't signal EOF"); + ok(feof(file) !=0,"feof doesn't signal EOF"); + rewind(file); + ok(fgetws(wbuffer,strlen(outbuffer),file) !=0,"fgetws failed unexpected"); + ok(lstrlenW(wbuffer) == (strlen(outbuffer) -1),"fgetws didn't read right size"); + ok(fgetws(wbuffer,sizeof(outbuffer),file) !=0,"fgets failed unexpected"); + ok(lstrlenW(wbuffer) == 1,"fgets dropped chars"); + fclose (file); + close (fd); + unlink ("fdopen.tst"); +} + static WCHAR* AtoW( char* p ) { WCHAR* buffer; @@ -181,6 +223,7 @@ START_TEST(file) { test_fdopen(); + test_fileops(); test_fgetwc(); test_file_put_get(); test_file_write_read();