dlls/kernel/tests/file.c smaller, verified against Win95B, latest CVS, no bugs ;-)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





license: LGPL

coherent indentation, fewer LOC, better macro support for
Windows target (EXE)

Removed redundant checks and variables.


Thanks to a new define, I can compile all tests for Windows with:
  
i586-mingw32msvc-gcc -o file.exe -DREAL_EXE file.c

include file "unittest.h" is at bottom of message.
 
 -----------------------------------------------------------

Index: file.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/file.c,v
retrieving revision 1.6
diff -u -r1.6 file.c
--- file.c	23 May 2002 16:29:37 -0000	1.6
+++ file.c	23 May 2002 22:32:07 -0000
@@ -1,4 +1,5 @@
-/*
+/* -*- wine-c -*-
+ *
  * Unit tests for file functions in Wine
  *
  * Copyright (c) 2002 Jakob Eriksson
@@ -19,13 +20,24 @@
  *
  */
 
+
+/* 
+ * Compile tests for Windows with:
+ *
+ * i586-mingw32msvc-gcc -DREAL_EXE -o file.exe file.c
+ *
+ *
+ * I'm planning on a Wine global unit test EXE builder with a twist. Stand by.
+ * Help very much appreciated!
+ * /jakob@vmlinux.org
+ *
+ */
+
+#include "unittest.h"
+
 #include <stdlib.h>
 #include <time.h>
 
-#include "wine/test.h"
-#include "winbase.h"
-#include "winerror.h"
-
 
 LPCSTR filename = "testfile.xxx";
 LPCSTR sillytext =
@@ -48,41 +60,36 @@
     long bytes_read;
     long bytes_wanted;
     UINT i;
-    int rc;
 
     filehandle = _lcreat( filename, 0 );
-    if (filehandle == HFILE_ERROR)
-    {
-        ok(0,"couldn't create file \"%s\" (err=%d)",filename,GetLastError());
-        return;
-    }
 
-    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains." );
+    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)", filename, GetLastError(  ) );
+
+    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains" );
 
-    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
     filehandle = _lopen( filename, OF_READ );
 
-    ok( HFILE_ERROR != filehandle, "couldn't open file \"%s\" again (err=%d)", filename, GetLastError());
+    ok( HFILE_ERROR != filehandle, "couldn't open file \"%s\" again (err=%d)", filename, GetLastError(  ) );
 
     bytes_read = _hread( filehandle, buffer, 2 * strlen( sillytext ) );
 
-    ok( strlen( sillytext ) == bytes_read, "file read size error." );
+    ok( strlen( sillytext ) == bytes_read, "file read size error" );
 
     for (bytes_wanted = 0; bytes_wanted < strlen( sillytext ); bytes_wanted++)
     {
-        ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains." );
-        ok( _hread( filehandle, buffer, bytes_wanted ) == bytes_wanted, "erratic _hread return value." );
+        ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains" );
+        ok( _hread( filehandle, buffer, bytes_wanted ) == bytes_wanted, "erratic _hread return value" );
         for (i = 0; i < bytes_wanted; i++)
         {
-            ok( buffer[i] == sillytext[i], "that's not what's written." );
+            ok( buffer[i] == sillytext[i], "that's not what's written" );
         }
     }
 
-    ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains" );
 
-    rc=DeleteFileA(filename);
-    ok( rc != 0, "DeleteFile failed (%d).", GetLastError());
+    ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%d)", GetLastError(  ) );
 }
 
 
@@ -97,26 +104,21 @@
     char *contents;
     HLOCAL memory_object;
     char checksum[1];
-    int rc;
 
     filehandle = _lcreat( filename, 0 );
-    if (filehandle == HFILE_ERROR)
-    {
-        ok(0,"couldn't create file \"%s\" (err=%d)",filename,GetLastError());
-        return;
-    }
+    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)", filename, GetLastError(  ) );
 
-    ok( HFILE_ERROR != _hwrite( filehandle, "", 0 ), "_hwrite complains." );
+    ok( HFILE_ERROR != _hwrite( filehandle, "", 0 ), "_hwrite complains" );
 
-    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
     filehandle = _lopen( filename, OF_READ );
 
     bytes_read = _hread( filehandle, buffer, 1);
 
-    ok( 0 == bytes_read, "file read size error." );
+    ok( 0 == bytes_read, "file read size error" );
 
-    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
     filehandle = _lopen( filename, OF_READWRITE );
 
@@ -130,14 +132,14 @@
             buffer[i] = rand(  );
             checksum[0] = checksum[0] + buffer[i];
         }
-        ok( HFILE_ERROR != _hwrite( filehandle, buffer, sizeof( buffer ) ), "_hwrite complains." );
+        ok( HFILE_ERROR != _hwrite( filehandle, buffer, sizeof( buffer ) ), "_hwrite complains" );
         bytes_written = bytes_written + sizeof( buffer );
     }
 
-    ok( HFILE_ERROR != _hwrite( filehandle, checksum, 1 ), "_hwrite complains." );
+    ok( HFILE_ERROR != _hwrite( filehandle, checksum, 1 ), "_hwrite complains" );
     bytes_written++;
 
-    ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains" );
 
     memory_object = LocalAlloc( LPTR, bytes_written );
 
@@ -149,9 +151,9 @@
 
     contents = LocalLock( memory_object );
 
-    ok( NULL != contents, "LocalLock whines." );
+    ok( NULL != contents, "LocalLock whines" );
 
-    ok( bytes_written == _hread( filehandle, contents, bytes_written), "read length differ from write length." );
+    ok( bytes_written == _hread( filehandle, contents, bytes_written), "read length differ from write length" );
 
     checksum[0] = '\0';
     i = 0;
@@ -162,37 +164,30 @@
     }
     while (i < bytes_written - 1);
 
-    ok( checksum[0] == contents[i], "stored checksum differ from computed checksum." );
+    ok( checksum[0] == contents[i], "stored checksum differ from computed checksum" );
 
-    ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains" );
 
-    rc=DeleteFileA(filename);
-    ok( rc != 0, "DeleteFile failed (%d).", GetLastError());
+    ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%d)", GetLastError(  ) );
 }
 
 
 static void test__lclose( void )
 {
     HFILE filehandle;
-    int rc;
 
     filehandle = _lcreat( filename, 0 );
-    if (filehandle == HFILE_ERROR)
-    {
-        ok(0,"couldn't create file \"%s\" (err=%d)",filename,GetLastError());
-        return;
-    }
+    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)", filename, GetLastError(  ) );
 
-    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains." );
+    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains" );
 
-    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
-    ok( HFILE_ERROR == _lclose(filehandle), "_lclose should whine about this." );
+    ok( HFILE_ERROR == _lclose(filehandle), "_lclose should whine about this" );
 
-    ok( HFILE_ERROR == _lclose(filehandle), "_lclose should whine about this." );
+    ok( HFILE_ERROR == _lclose(filehandle), "_lclose should whine about this" );
 
-    rc=DeleteFileA(filename);
-    ok( rc != 0, "DeleteFile failed (%d).", GetLastError());
+    ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%d)", GetLastError(  ) );
 }
 
 
@@ -201,78 +196,69 @@
     HFILE filehandle;
     char buffer[10000];
     WIN32_FIND_DATAA search_results;
-    int rc;
 
     filehandle = _lcreat( filename, 0 );
-    if (filehandle == HFILE_ERROR)
-    {
-        ok(0,"couldn't create file \"%s\" (err=%d)",filename,GetLastError());
-        return;
-    }
+    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)", filename, GetLastError(  ) );
 
-    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains." );
+    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains" );
 
-    ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains." );
+    ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains" );
 
-    ok( _hread( filehandle, buffer, strlen( sillytext ) ) ==  strlen( sillytext ), "erratic _hread return value." );
+    ok( _hread( filehandle, buffer, strlen( sillytext ) ) ==  strlen( sillytext ), "erratic _hread return value" );
 
-    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
     ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should be able to find file" );
 
-    rc=DeleteFileA(filename);
-    ok( rc != 0, "DeleteFile failed (%d).", GetLastError());
+    ok( DeleteFileA(filename) != 0, "DeleteFile failed (%d)", GetLastError());
 
-    filehandle = _lcreat( filename, 1 );
-    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)", filename, GetLastError());
+    filehandle = _lcreat( filename, 1 ); /* readonly */
+    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)", filename, GetLastError(  ) );
 
-    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite shouldn't be able to write never the less." );
+    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite shouldn't be able to write never the less" );
 
-    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
     ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should be able to find file" );
 
-    rc=DeleteFileA(filename);
-    ok( rc != 0, "DeleteFile failed (%d).", GetLastError());
+    todo_wine
+    {
+        ok( 0 == DeleteFileA( filename ), "shouldn't be able to delete a readonly file" );
 
+        ok( SetFileAttributesA(filename, FILE_ATTRIBUTE_NORMAL ) != 0, "couldn't change attributes on file" );
+
+        ok( DeleteFileA( filename ) != 0, "now it should be possible to delete the file!" );
+    }
 
     filehandle = _lcreat( filename, 2 );
-    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)", filename, GetLastError());
+    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)", filename, GetLastError(  ) );
 
-    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains." );
+    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains" );
 
-    ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains." );
+    ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains" );
 
-    ok( _hread( filehandle, buffer, strlen( sillytext ) ) ==  strlen( sillytext ), "erratic _hread return value." );
+    ok( _hread( filehandle, buffer, strlen( sillytext ) ) ==  strlen( sillytext ), "erratic _hread return value" );
 
-    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
-    todo_wine
-    {
-        ok( INVALID_HANDLE_VALUE == FindFirstFileA( filename, &search_results ), "should NOT be able to find file" );
-    }
+    ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should STILL be able to find file" );
 
-    rc=DeleteFileA(filename);
-    ok( rc != 0, "DeleteFile failed (%d).", GetLastError());
+    ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%d)", GetLastError(  ) );
 
-    filehandle = _lcreat( filename, 4 );
-    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)", filename, GetLastError());
+    filehandle = _lcreat( filename, 4 ); /* SYSTEM file */
+    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)", filename, GetLastError(  ) );
 
-    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains." );
+    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains" );
 
-    ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains." );
+    ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains" );
 
-    ok( _hread( filehandle, buffer, strlen( sillytext ) ) ==  strlen( sillytext ), "erratic _hread return value." );
+    ok( _hread( filehandle, buffer, strlen( sillytext ) ) ==  strlen( sillytext ), "erratic _hread return value" );
 
-    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
-    todo_wine
-    {
-        ok( INVALID_HANDLE_VALUE == FindFirstFileA( filename, &search_results ), "should NOT be able to find file" );
-    }
+    ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should STILL be able to find file" );
 
-    rc=DeleteFileA(filename);
-    ok( rc != 0, "DeleteFile failed (%d).", GetLastError());
+    ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%d)", GetLastError(  ) );
 }
 
 
@@ -282,35 +268,29 @@
     HFILE filehandle;
     char buffer[1];
     long bytes_read;
-    int rc;
 
     filehandle = _lcreat( filename, 0 );
-    if (filehandle == HFILE_ERROR)
-    {
-        ok(0,"couldn't create file \"%s\" (err=%d)",filename,GetLastError());
-        return;
-    }
+    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)", filename, GetLastError(  ) );
 
     for (i = 0; i < 400; i++)
     {
-        ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains." );
+        ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains" );
     }
     ok( HFILE_ERROR != _llseek( filehandle, 400 * strlen( sillytext ), FILE_CURRENT ), "should be able to seek" );
     ok( HFILE_ERROR != _llseek( filehandle, 27 + 35 * strlen( sillytext ), FILE_BEGIN ), "should be able to seek" );
 
     bytes_read = _hread( filehandle, buffer, 1);
-    ok( 1 == bytes_read, "file read size error." );
-    ok( buffer[0] == sillytext[27], "_llseek error. It got lost seeking..." );
+    ok( 1 == bytes_read, "file read size error" );
+    ok( buffer[0] == sillytext[27], "_llseek error, it got lost seeking" );
     ok( HFILE_ERROR != _llseek( filehandle, -400 * strlen( sillytext ), FILE_END ), "should be able to seek" );
 
     bytes_read = _hread( filehandle, buffer, 1);
-    ok( 1 == bytes_read, "file read size error." );
-    ok( buffer[0] == sillytext[0], "_llseek error. It got lost seeking..." );
-    ok( HFILE_ERROR != _llseek( filehandle, 1000000, FILE_END ), "should be able to seek past file. Poor, poor Windows programmers." );
-    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+    ok( 1 == bytes_read, "file read size error" );
+    ok( buffer[0] == sillytext[0], "_llseek error, it got lost seeking" );
+    ok( HFILE_ERROR != _llseek( filehandle, 1000000, FILE_END ), "should be able to seek past file; poor, poor Windows programmers" );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
-    rc=DeleteFileA(filename);
-    ok( rc != 0, "DeleteFile failed (%d).", GetLastError());
+    ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%d)", GetLastError(  ) );
 }
 
 
@@ -319,37 +299,31 @@
     HFILE filehandle;
     UINT bytes_read;
     char buffer[10000];
-    int rc;
 
     filehandle = _lcreat( filename, 0 );
-    if (filehandle == HFILE_ERROR)
-    {
-        ok(0,"couldn't create file \"%s\" (err=%d)",filename,GetLastError());
-        return;
-    }
+    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)", filename, GetLastError(  ) );
 
-    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains." );
-    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains" );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
     filehandle = _lopen( filename, OF_READ );
     ok( HFILE_ERROR == _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite shouldn't be able to write!" );
     bytes_read = _hread( filehandle, buffer, strlen( sillytext ) );
-    ok( strlen( sillytext )  == bytes_read, "file read size error." );
-    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+    ok( strlen( sillytext )  == bytes_read, "file read size error" );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
     filehandle = _lopen( filename, OF_READWRITE );
     bytes_read = _hread( filehandle, buffer, 2 * strlen( sillytext ) );
-    ok( strlen( sillytext )  == bytes_read, "file read size error." );
-    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite should write just fine." );
-    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+    ok( strlen( sillytext )  == bytes_read, "file read size error" );
+    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite should write just fine" );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
     filehandle = _lopen( filename, OF_WRITE );
-    ok( HFILE_ERROR == _hread( filehandle, buffer, 1 ), "you should only be able to write this file..." );
-    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite should write just fine." );
-    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+    ok( HFILE_ERROR == _hread( filehandle, buffer, 1 ), "you should only be able to write this file" );
+    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite should write just fine" );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
-    rc=DeleteFileA(filename);
-    ok( rc != 0, "DeleteFile failed (%d).", GetLastError());
+    ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%d)", GetLastError(  ) );
     /* TODO - add tests for the SHARE modes  -  use two processes to pull this one off */
 }
 
@@ -361,18 +335,13 @@
     long bytes_read;
     UINT bytes_wanted;
     UINT i;
-    int rc;
 
     filehandle = _lcreat( filename, 0 );
-    if (filehandle == HFILE_ERROR)
-    {
-        ok(0,"couldn't create file \"%s\" (err=%d)",filename,GetLastError());
-        return;
-    }
+    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)", filename, GetLastError(  ) );
 
-    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains." );
+    ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains" );
 
-    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
     filehandle = _lopen( filename, OF_READ );
 
@@ -380,22 +349,21 @@
 
     bytes_read = _lread( filehandle, buffer, 2 * strlen( sillytext ) );
 
-    ok( strlen( sillytext ) == bytes_read, "file read size error." );
+    ok( strlen( sillytext ) == bytes_read, "file read size error" );
 
     for (bytes_wanted = 0; bytes_wanted < strlen( sillytext ); bytes_wanted++)
     {
-        ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains." );
-        ok( _lread( filehandle, buffer, bytes_wanted ) == bytes_wanted, "erratic _hread return value." );
+        ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains" );
+        ok( _lread( filehandle, buffer, bytes_wanted ) == bytes_wanted, "erratic _hread return value" );
         for (i = 0; i < bytes_wanted; i++)
         {
-            ok( buffer[i] == sillytext[i], "that's not what's written." );
+            ok( buffer[i] == sillytext[i], "that's not what's written" );
         }
     }
 
-    ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
-    rc=DeleteFileA(filename);
-    ok( rc != 0, "DeleteFile failed (%d).", GetLastError());
+    ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%d)", GetLastError(  ) );
 }
 
 
@@ -410,26 +378,21 @@
     char *contents;
     HLOCAL memory_object;
     char checksum[1];
-    int rc;
 
     filehandle = _lcreat( filename, 0 );
-    if (filehandle == HFILE_ERROR)
-    {
-        ok(0,"couldn't create file \"%s\" (err=%d)",filename,GetLastError());
-        return;
-    }
+    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)", filename, GetLastError(  ) );
 
-    ok( HFILE_ERROR != _lwrite( filehandle, "", 0 ), "_hwrite complains." );
+    ok( HFILE_ERROR != _lwrite( filehandle, "", 0 ), "_hwrite complains" );
 
-    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
     filehandle = _lopen( filename, OF_READ );
 
     bytes_read = _hread( filehandle, buffer, 1);
 
-    ok( 0 == bytes_read, "file read size error." );
+    ok( 0 == bytes_read, "file read size error" );
 
-    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
 
     filehandle = _lopen( filename, OF_READWRITE );
 
@@ -443,18 +406,18 @@
             buffer[i] = rand(  );
             checksum[0] = checksum[0] + buffer[i];
         }
-        ok( HFILE_ERROR != _lwrite( filehandle, buffer, sizeof( buffer ) ), "_hwrite complains." );
+        ok( HFILE_ERROR != _lwrite( filehandle, buffer, sizeof( buffer ) ), "_hwrite complains" );
         bytes_written = bytes_written + sizeof( buffer );
     }
 
-    ok( HFILE_ERROR != _lwrite( filehandle, checksum, 1 ), "_hwrite complains." );
+    ok( HFILE_ERROR != _lwrite( filehandle, checksum, 1 ), "_hwrite complains" );
     bytes_written++;
 
-    ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains" );
 
     memory_object = LocalAlloc( LPTR, bytes_written );
 
-    ok( 0 != memory_object, "LocalAlloc fails. (Could be out of memory.)" );
+    ok( 0 != memory_object, "LocalAlloc fails, could be out of memory" );
 
     contents = LocalLock( memory_object );
 
@@ -462,25 +425,24 @@
 
     contents = LocalLock( memory_object );
 
-    ok( NULL != contents, "LocalLock whines." );
+    ok( NULL != contents, "LocalLock whines" );
 
-    ok( bytes_written == _hread( filehandle, contents, bytes_written), "read length differ from write length." );
+    ok( bytes_written == _hread( filehandle, contents, bytes_written), "read length differ from write length" );
 
     checksum[0] = '\0';
     i = 0;
     do
     {
-        checksum[0] = checksum[0] + contents[i];
+        checksum[0] += contents[i];
         i++;
     }
     while (i < bytes_written - 1);
 
-    ok( checksum[0] == contents[i], "stored checksum differ from computed checksum." );
+    ok( checksum[0] == contents[i], "stored checksum differ from computed checksum" );
 
-    ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains." );
+    ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains" );
 
-    rc=DeleteFileA(filename);
-    ok( rc != 0, "DeleteFile failed (%d).", GetLastError());
+    ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%d)", GetLastError(  ) );
 }
 
 



  ------------------------------------------------------------

  You also need this include file "unittest.h":


#ifndef _UNITTEST_H
#define _UNITTEST_H


#ifndef REAL_EXE



#include "winbase.h"
#include "winerror.h"
#include "wine/test.h"



#else

#include <windows.h>
#include <stdio.h>
static line_passed = 0;
static tests_passed = 0;


#define ok(val,...)  \
{ \
    if (!(val))  \
    {  \
        printf (__VA_ARGS__);  \
        printf(" %s:%d\n", __FILE__, __LINE__); \
        ExitProcess(1); \
    }  \
    else  \
    { \
        if (__LINE__ > line_passed)   \
        {  \
            printf("test %d OK (%s:%d)\n", tests_passed, __FILE__, __LINE__);  \
            line_passed = __LINE__;  \
            tests_passed++; \
         } \
    } \
}


#define todo_wine
#define START_TEST main

#endif /* ! REAL_EXE */

#endif /* _UNITTEST_H */



[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux