Correct use of the ok function in user/tests and kernel/tests
Rein Klazes
wijn at wanadoo.nl
Thu Dec 23 08:57:33 CST 2004
Hi,
82 cases, most a variation of:
ok( !Foo(), "Foo failed, error %ld\n", GetLastError());
Changelog:
dlls/kernel/tests : change.c, file.c, process.c,
thread.c, time.c
dlls/user/tests : clipboard.c, msg.c, text.c win.c
Correct cases where arguments of ok() calls depend on the order
in which they are evaluated.
Rein.
-------------- next part --------------
--- wine/dlls/kernel/tests/change.c 2004-11-04 10:17:29.000000000 +0100
+++ mywine/dlls/kernel/tests/change.c 2004-12-22 19:43:39.000000000 +0100
@@ -44,7 +44,8 @@ static DWORD CALLBACK NotificationThread
ret = FindNextChangeNotification(change);
}
- ok(FindCloseChangeNotification(change), "FindCloseChangeNotification error: %ld\n",
+ ret = FindCloseChangeNotification(change);
+ ok( ret, "FindCloseChangeNotification error: %ld\n",
GetLastError());
ExitThread((DWORD)ret);
@@ -123,7 +124,8 @@ static void test_FindFirstChangeNotifica
file = CreateFileA(filename1, GENERIC_WRITE|GENERIC_READ, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, 0);
ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %ld\n", GetLastError());
- ok(CloseHandle(file), "CloseHandle error: %ld\n", GetLastError());
+ ret = CloseHandle(file);
+ ok( ret, "CloseHandle error: %ld\n", GetLastError());
/* Try to register notification for a file. win98 and win2k behave differently here */
change = FindFirstChangeNotificationA(filename1, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
@@ -189,7 +191,8 @@ static void test_FindFirstChangeNotifica
file = CreateFileA(filename2, GENERIC_WRITE|GENERIC_READ, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, 0);
ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %ld\n", GetLastError());
- ok(CloseHandle(file), "CloseHandle error: %ld\n", GetLastError());
+ ret = CloseHandle(file);
+ ok( ret, "CloseHandle error: %ld\n", GetLastError());
ok(FinishNotificationThread(thread), "Missed notification\n");
attributes = GetFileAttributesA(filename2);
@@ -209,7 +212,8 @@ static void test_FindFirstChangeNotifica
ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %ld\n", GetLastError());
ret = WriteFile(file, buffer, sizeof(buffer), &count, NULL);
ok(ret && count == sizeof(buffer), "WriteFile error: %ld\n", GetLastError());
- ok(CloseHandle(file), "CloseHandle error: %ld\n", GetLastError());
+ ret = CloseHandle(file);
+ ok( ret, "CloseHandle error: %ld\n", GetLastError());
ok(FinishNotificationThread(thread), "Missed notification\n");
/* Change file size by truncating a file */
@@ -219,7 +223,8 @@ static void test_FindFirstChangeNotifica
ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %ld\n", GetLastError());
ret = WriteFile(file, buffer, sizeof(buffer) / 2, &count, NULL);
ok(ret && count == sizeof(buffer) / 2, "WriteFileA error: %ld\n", GetLastError());
- ok(CloseHandle(file), "CloseHandle error: %ld\n", GetLastError());
+ ret = CloseHandle(file);
+ ok( ret, "CloseHandle error: %ld\n", GetLastError());
ok(FinishNotificationThread(thread), "Missed notification\n");
/* clean up */
--- wine/dlls/kernel/tests/file.c 2004-12-02 09:23:34.000000000 +0100
+++ mywine/dlls/kernel/tests/file.c 2004-12-22 20:36:38.000000000 +0100
@@ -58,6 +58,7 @@ static void test__hread( void )
long bytes_read;
long bytes_wanted;
long i;
+ BOOL ret;
SetFileAttributesA(filename,FILE_ATTRIBUTE_NORMAL); /* be sure to remove stale files */
DeleteFileA( filename );
@@ -92,7 +93,8 @@ static void test__hread( void )
ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains\n" );
- ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
+ ret = DeleteFileA( filename );
+ ok( ret != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
}
@@ -107,6 +109,7 @@ static void test__hwrite( void )
char *contents;
HLOCAL memory_object;
char checksum[1];
+ BOOL ret;
filehandle = _lcreat( filename, 0 );
if (filehandle == HFILE_ERROR)
@@ -175,13 +178,15 @@ static void test__hwrite( void )
ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains\n" );
- ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
+ ret = DeleteFileA( filename );
+ ok( ret != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
}
static void test__lclose( void )
{
HFILE filehandle;
+ BOOL ret;
filehandle = _lcreat( filename, 0 );
if (filehandle == HFILE_ERROR)
@@ -194,7 +199,8 @@ static void test__lclose( void )
ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
- ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
+ ret = DeleteFileA( filename );
+ ok( ret != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
}
@@ -206,6 +212,7 @@ static void test__lcreat( void )
char slashname[] = "testfi/";
int err;
HANDLE find;
+ BOOL ret;
filehandle = _lcreat( filename, 0 );
if (filehandle == HFILE_ERROR)
@@ -224,7 +231,8 @@ static void test__lcreat( void )
ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should be able to find file\n" );
- ok( DeleteFileA(filename) != 0, "DeleteFile failed (%ld)\n", GetLastError());
+ ret = DeleteFileA(filename);
+ ok( ret != 0, "DeleteFile failed (%ld)\n", GetLastError());
filehandle = _lcreat( filename, 1 ); /* readonly */
ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%ld)\n", filename, GetLastError( ) );
@@ -254,7 +262,8 @@ static void test__lcreat( void )
ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should STILL be able to find file\n" );
- ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
+ ret = DeleteFileA( filename );
+ ok( ret, "DeleteFile failed (%ld)\n", GetLastError( ) );
filehandle = _lcreat( filename, 4 ); /* SYSTEM file */
ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%ld)\n", filename, GetLastError( ) );
@@ -269,7 +278,8 @@ static void test__lcreat( void )
ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should STILL be able to find file\n" );
- ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
+ ret = DeleteFileA( filename );
+ ok( ret, "DeleteFile failed (%ld)\n", GetLastError( ) );
filehandle=_lcreat (slashname, 0); /* illegal name */
if (HFILE_ERROR==filehandle) {
@@ -281,7 +291,8 @@ static void test__lcreat( void )
find=FindFirstFileA (slashname, &search_results);
if (INVALID_HANDLE_VALUE!=find)
{
- ok (0!=FindClose (find), "FindClose complains (%ld)\n", GetLastError ());
+ ret = FindClose (find);
+ ok (0 != ret, "FindClose complains (%ld)\n", GetLastError ());
slashname[strlen(slashname)-1]=0;
ok (!strcmp (slashname, search_results.cFileName),
"found unexpected name \"%s\"\n", search_results.cFileName);
@@ -289,8 +300,8 @@ static void test__lcreat( void )
"attributes of file \"%s\" are 0x%04lx\n", search_results.cFileName,
search_results.dwFileAttributes);
}
- ok (0!=DeleteFileA (slashname), "Can't delete \"%s\" (%ld)\n", slashname,
- GetLastError ());
+ ret = DeleteFileA( slashname );
+ ok( ret, "DeleteFile failed (%ld)\n", GetLastError( ) );
}
filehandle=_lcreat (filename, 8); /* illegal attribute */
@@ -302,15 +313,16 @@ static void test__lcreat( void )
if (INVALID_HANDLE_VALUE==find)
ok (0, "file \"%s\" not found\n", filename);
else {
- ok (0!=FindClose (find), "FindClose complains (%ld)\n", GetLastError ());
+ ret = FindClose(find);
+ ok ( 0 != ret, "FindClose complains (%ld)\n", GetLastError ());
ok (!strcmp (filename, search_results.cFileName),
"found unexpected name \"%s\"\n", search_results.cFileName);
ok (FILE_ATTRIBUTE_ARCHIVE==search_results.dwFileAttributes,
"attributes of file \"%s\" are 0x%04lx\n", search_results.cFileName,
search_results.dwFileAttributes);
}
- ok (0!=DeleteFileA (filename), "Can't delete \"%s\" (%ld)\n", slashname,
- GetLastError ());
+ ret = DeleteFileA( filename );
+ ok( ret, "DeleteFile failed (%ld)\n", GetLastError( ) );
}
}
@@ -321,6 +333,7 @@ static void test__llseek( void )
HFILE filehandle;
char buffer[1];
long bytes_read;
+ BOOL ret;
filehandle = _lcreat( filename, 0 );
if (filehandle == HFILE_ERROR)
@@ -347,7 +360,8 @@ static void test__llseek( void )
ok( HFILE_ERROR != _llseek( filehandle, 1000000, FILE_END ), "should be able to seek past file; poor, poor Windows programmers\n" );
ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
- ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
+ ret = DeleteFileA( filename );
+ ok( ret, "DeleteFile failed (%ld)\n", GetLastError( ) );
}
@@ -356,6 +370,7 @@ static void test__llopen( void )
HFILE filehandle;
UINT bytes_read;
char buffer[10000];
+ BOOL ret;
filehandle = _lcreat( filename, 0 );
if (filehandle == HFILE_ERROR)
@@ -384,7 +399,8 @@ static void test__llopen( void )
ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite should write just fine\n" );
ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
- ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
+ ret = DeleteFileA( filename );
+ ok( ret, "DeleteFile failed (%ld)\n", GetLastError( ) );
/* TODO - add tests for the SHARE modes - use two processes to pull this one off */
}
@@ -396,6 +412,7 @@ static void test__lread( void )
long bytes_read;
UINT bytes_wanted;
UINT i;
+ BOOL ret;
filehandle = _lcreat( filename, 0 );
if (filehandle == HFILE_ERROR)
@@ -428,7 +445,8 @@ static void test__lread( void )
ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
- ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
+ ret = DeleteFileA( filename );
+ ok( ret, "DeleteFile failed (%ld)\n", GetLastError( ) );
}
@@ -443,6 +461,7 @@ static void test__lwrite( void )
char *contents;
HLOCAL memory_object;
char checksum[1];
+ BOOL ret;
filehandle = _lcreat( filename, 0 );
if (filehandle == HFILE_ERROR)
@@ -511,7 +530,8 @@ static void test__lwrite( void )
ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains\n" );
- ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
+ ret = DeleteFileA( filename );
+ ok( ret, "DeleteFile failed (%ld)\n", GetLastError( ) );
}
static void test_CopyFileA(void)
@@ -522,6 +542,7 @@ static void test_CopyFileA(void)
HANDLE hfile;
char buf[10];
DWORD ret;
+ BOOL retok;
ret = GetTempPathA(MAX_PATH, temp_path);
ok(ret != 0, "GetTempPathA error %ld\n", GetLastError());
@@ -533,7 +554,8 @@ static void test_CopyFileA(void)
/* make the source have not zero size */
hfile = CreateFileA(source, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0 );
ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file\n");
- ok(WriteFile(hfile, prefix, sizeof(prefix), &ret, NULL ) && ret == sizeof(prefix),
+ retok = WriteFile(hfile, prefix, sizeof(prefix), &ret, NULL );
+ ok( retok && ret == sizeof(prefix),
"WriteFile error %ld\n", GetLastError());
ok(GetFileSize(hfile, NULL) == sizeof(prefix), "source file has wrong size\n");
CloseHandle(hfile);
@@ -563,7 +585,8 @@ static void test_CopyFileA(void)
/* make sure that destination still has correct size */
ret = GetFileSize(hfile, NULL);
ok(ret == sizeof(prefix), "destination file has wrong size %ld\n", ret);
- ok(ReadFile(hfile, buf, sizeof(buf), &ret, NULL) && ret == sizeof(prefix),
+ retok = ReadFile(hfile, buf, sizeof(buf), &ret, NULL);
+ ok( retok && ret == sizeof(prefix),
"ReadFile: error %ld\n", GetLastError());
ok(!memcmp(prefix, buf, sizeof(prefix)), "buffer contents mismatch\n");
CloseHandle(hfile);
@@ -861,9 +884,12 @@ static void test_offset_in_overlapped_st
BYTE buf[256], pattern[] = "TeSt";
UINT i;
char temp_path[MAX_PATH], temp_fname[MAX_PATH];
+ BOOL ret;
- ok(GetTempPathA(MAX_PATH, temp_path) != 0, "GetTempPathA error %ld\n", GetLastError());
- ok(GetTempFileNameA(temp_path, "pfx", 0, temp_fname) != 0, "GetTempFileNameA error %ld\n", GetLastError());
+ ret =GetTempPathA(MAX_PATH, temp_path);
+ ok( ret, "GetTempPathA error %ld\n", GetLastError());
+ ret =GetTempFileNameA(temp_path, "pfx", 0, temp_fname);
+ ok( ret, "GetTempFileNameA error %ld\n", GetLastError());
/*** Write File *****************************************************/
@@ -871,7 +897,8 @@ static void test_offset_in_overlapped_st
ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA error %ld\n", GetLastError());
for(i = 0; i < sizeof(buf); i++) buf[i] = i;
- ok(WriteFile(hFile, buf, sizeof(buf), &done, NULL), "WriteFile error %ld\n", GetLastError());
+ ret = WriteFile(hFile, buf, sizeof(buf), &done, NULL);
+ ok( ret, "WriteFile error %ld\n", GetLastError());
ok(done == sizeof(buf), "expected number of bytes written %lu\n", done);
memset(&ov, 0, sizeof(ov));
@@ -888,7 +915,8 @@ static void test_offset_in_overlapped_st
ov.Offset = sizeof(buf) * 2;
ov.OffsetHigh = 0;
- ok(WriteFile(hFile, pattern, sizeof(pattern), &done, &ov), "WriteFile error %ld\n", GetLastError());
+ ret = WriteFile(hFile, pattern, sizeof(pattern), &done, &ov);
+ ok( ret, "WriteFile error %ld\n", GetLastError());
ok(done == sizeof(pattern), "expected number of bytes written %lu\n", done);
/*trace("Current offset = %04lx\n", SetFilePointer(hFile, 0, NULL, FILE_CURRENT));*/
ok(SetFilePointer(hFile, 0, NULL, FILE_CURRENT) == (sizeof(buf) * 2 + sizeof(pattern)),
@@ -919,7 +947,8 @@ static void test_offset_in_overlapped_st
CloseHandle(hFile);
- ok(DeleteFileA(temp_fname), "DeleteFileA error %ld\n", GetLastError());
+ ret = DeleteFileA(temp_fname);
+ ok( ret, "DeleteFileA error %ld\n", GetLastError());
}
static void test_LockFile(void)
@@ -1316,8 +1345,10 @@ static void test_read_write(void)
"ret = %ld, error %ld\n", ret, GetLastError());
ok(!bytes, "bytes = %ld\n", bytes);
- ok(CloseHandle(hFile), "CloseHandle: error %ld\n", GetLastError());
- ok(DeleteFileA(filename), "DeleteFileA: error %ld\n", GetLastError());
+ ret = CloseHandle(hFile);
+ ok( ret, "CloseHandle: error %ld\n", GetLastError());
+ ret = DeleteFileA(filename);
+ ok( ret, "DeleteFileA: error %ld\n", GetLastError());
}
START_TEST(file)
--- wine/dlls/kernel/tests/process.c 2004-11-23 12:04:50.000000000 +0100
+++ mywine/dlls/kernel/tests/process.c 2004-12-22 20:53:47.000000000 +0100
@@ -202,6 +202,7 @@ static void doChild(const char* file
char bufA[MAX_PATH];
WCHAR bufW[MAX_PATH];
HANDLE hFile = CreateFileA(file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
+ BOOL ret;
if (hFile == INVALID_HANDLE_VALUE) return;
@@ -329,11 +330,14 @@ static void doChild(const char* file
/* now that we have written all relevant information, let's change it */
ok(SetConsoleCP(1252), "Setting CP\n");
ok(SetConsoleOutputCP(1252), "Setting SB CP\n");
- ok(SetConsoleMode(hConIn, modeIn ^ 1), "Setting mode (%ld)\n", GetLastError());
- ok(SetConsoleMode(hConOut, modeOut ^ 1), "Setting mode (%ld)\n", GetLastError());
+ ret = SetConsoleMode(hConIn, modeIn ^ 1);
+ ok( ret, "Setting mode (%ld)\n", GetLastError());
+ ret = SetConsoleMode(hConOut, modeOut ^ 1);
+ ok( ret, "Setting mode (%ld)\n", GetLastError());
sbi.dwCursorPosition.X ^= 1;
sbi.dwCursorPosition.Y ^= 1;
- ok(SetConsoleCursorPosition(hConOut, sbi.dwCursorPosition), "Setting cursor position (%ld)\n", GetLastError());
+ ret = SetConsoleCursorPosition(hConOut, sbi.dwCursorPosition);
+ ok( ret, "Setting cursor position (%ld)\n", GetLastError());
}
if (option && strcmp(option, "stdhandle") == 0)
{
--- wine/dlls/kernel/tests/thread.c 2004-12-20 18:18:49.000000000 +0100
+++ mywine/dlls/kernel/tests/thread.c 2004-12-22 20:54:28.000000000 +0100
@@ -438,14 +438,14 @@ VOID test_thread_priority(void)
if (rc!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED) {
ok(rc!=0,"error=%ld\n",GetLastError());
- ok(pSetThreadPriorityBoost(curthread,1)!=0,
- "error=%ld\n",GetLastError());
+ rc = pSetThreadPriorityBoost(curthread,1);
+ ok( rc != 0, "error=%ld\n",GetLastError());
rc=pGetThreadPriorityBoost(curthread,&disabled);
ok(rc!=0 && disabled==1,
"rc=%d error=%ld disabled=%d\n",rc,GetLastError(),disabled);
- ok(pSetThreadPriorityBoost(curthread,0)!=0,
- "error=%ld\n",GetLastError());
+ rc = pSetThreadPriorityBoost(curthread,0);
+ ok( rc != 0, "error=%ld\n",GetLastError());
rc=pGetThreadPriorityBoost(curthread,&disabled);
ok(rc!=0 && disabled==0,
"rc=%d error=%ld disabled=%d\n",rc,GetLastError(),disabled);
--- wine/dlls/kernel/tests/time.c 2004-11-06 11:32:22.000000000 +0100
+++ mywine/dlls/kernel/tests/time.c 2004-12-22 20:59:37.000000000 +0100
@@ -189,10 +189,12 @@ void test_FileTimeToSystemTime()
FILETIME ft;
SYSTEMTIME st;
ULONGLONG time = (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
+ BOOL ret;
ft.dwHighDateTime = 0;
ft.dwLowDateTime = 0;
- ok(FileTimeToSystemTime(&ft, &st),
+ ret = FileTimeToSystemTime(&ft, &st);
+ ok( ret,
"FileTimeToSystemTime() failed with Error 0x%08lx\n",GetLastError());
ok(((st.wYear == 1601) && (st.wMonth == 1) && (st.wDay == 1) &&
(st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 0) &&
@@ -201,7 +203,8 @@ void test_FileTimeToSystemTime()
ft.dwHighDateTime = (UINT)(time >> 32);
ft.dwLowDateTime = (UINT)time;
- ok(FileTimeToSystemTime(&ft, &st),
+ ret = FileTimeToSystemTime(&ft, &st);
+ ok( ret,
"FileTimeToSystemTime() failed with Error 0x%08lx\n",GetLastError());
ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
(st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 1) &&
@@ -222,10 +225,13 @@ void test_FileTimeToLocalFileTime()
( res == TIME_ZONE_ID_STANDARD ? tzinfo.StandardBias :
( res == TIME_ZONE_ID_DAYLIGHT ? tzinfo.DaylightBias : 0 ))) *
SECSPERMIN *TICKSPERSEC;
+ BOOL ret;
+
ok( res != TIME_ZONE_ID_INVALID , "GetTimeZoneInformation failed\n");
ft.dwHighDateTime = (UINT)(time >> 32);
ft.dwLowDateTime = (UINT)time;
- ok(FileTimeToLocalFileTime(&ft, &lft) !=0 ,
+ ret = FileTimeToLocalFileTime(&ft, &lft);
+ ok( ret,
"FileTimeToLocalFileTime() failed with Error 0x%08lx\n",GetLastError());
FileTimeToSystemTime(&lft, &st);
ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
@@ -238,7 +244,8 @@ void test_FileTimeToLocalFileTime()
ok(SetEnvironmentVariableA("TZ","GMT") != 0,
"SetEnvironmentVariableA failed\n");
ok(res != TIME_ZONE_ID_INVALID, "GetTimeZoneInformation failed\n");
- ok(FileTimeToLocalFileTime(&ft, &lft) !=0 ,
+ ret = FileTimeToLocalFileTime(&ft, &lft);
+ ok( ret,
"FileTimeToLocalFileTime() failed with Error 0x%08lx\n",GetLastError());
FileTimeToSystemTime(&lft, &st);
ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
--- wine/dlls/user/tests/clipboard.c 2004-09-08 08:31:05.000000000 +0200
+++ mywine/dlls/user/tests/clipboard.c 2004-12-22 21:18:26.000000000 +0100
@@ -37,6 +37,7 @@ static BOOL is_win9x = FALSE;
static void test_ClipboardOwner(void)
{
HWND hWnd1, hWnd2;
+ BOOL ret;
SetLastError(0xdeadbeef);
ok(!GetClipboardOwner() && GetLastError() == 0xdeadbeef,
@@ -59,7 +60,8 @@ static void test_ClipboardOwner(void)
ok(OpenClipboard(0), "OpenClipboard failed\n");
ok(!GetClipboardOwner(), "clipboard should still be not owned\n");
ok(!OpenClipboard(hWnd1), "OpenClipboard should fail since clipboard already opened\n");
- ok(CloseClipboard(), "CloseClipboard error %ld\n", GetLastError());
+ ret = CloseClipboard();
+ ok( ret, "CloseClipboard error %ld\n", GetLastError());
ok(OpenClipboard(hWnd1), "OpenClipboard failed\n");
@@ -69,18 +71,22 @@ static void test_ClipboardOwner(void)
SetLastError(0xdeadbeef);
ok(!GetClipboardOwner() && GetLastError() == 0xdeadbeef, "clipboard should still be not owned\n");
- ok(EmptyClipboard(), "EmptyClipboard error %ld\n", GetLastError());
+ ret = EmptyClipboard();
+ ok( ret, "EmptyClipboard error %ld\n", GetLastError());
ok(GetClipboardOwner() == hWnd1, "clipboard should be owned by %p, not by %p\n", hWnd1, GetClipboardOwner());
SetLastError(0xdeadbeef);
ok(!OpenClipboard(hWnd2) && GetLastError() == 0xdeadbeef,
"OpenClipboard should fail without setting last error value\n");
- ok(CloseClipboard(), "CloseClipboard error %ld\n", GetLastError());
+ ret = CloseClipboard();
+ ok( ret, "CloseClipboard error %ld\n", GetLastError());
ok(GetClipboardOwner() == hWnd1, "clipboard should still be owned\n");
- ok(DestroyWindow(hWnd1), "DestroyWindow error %ld\n", GetLastError());
- ok(DestroyWindow(hWnd2), "DestroyWindow error %ld\n", GetLastError());
+ ret = DestroyWindow(hWnd1);
+ ok( ret, "DestroyWindow error %ld\n", GetLastError());
+ ret = DestroyWindow(hWnd2);
+ ok( ret, "DestroyWindow error %ld\n", GetLastError());
SetLastError(0xdeadbeef);
ok(!GetClipboardOwner() && GetLastError() == 0xdeadbeef, "clipboard should not be owned\n");
}
@@ -91,6 +97,7 @@ static void test_RegisterClipboardFormat
UINT format_id, format_id2;
char buf[256];
int len;
+ BOOL ret;
format_id = RegisterClipboardFormatA("my_cool_clipboard_format");
ok(format_id > 0xc000 && format_id < 0xffff, "invalid clipboard format id %04x\n", format_id);
@@ -149,7 +156,8 @@ todo_wine
}
#endif
- ok(OpenClipboard(0), "OpenClipboard error %ld\n", GetLastError());
+ ret = OpenClipboard(0);
+ ok( ret, "OpenClipboard error %ld\n", GetLastError());
trace("# of formats available: %d\n", CountClipboardFormats());
@@ -161,8 +169,10 @@ todo_wine
trace("%04x: %s\n", format_id, len ? buf : "");
}
- ok(EmptyClipboard(), "EmptyClipboard error %ld\n", GetLastError());
- ok(CloseClipboard(), "CloseClipboard error %ld\n", GetLastError());
+ ret = EmptyClipboard();
+ ok( ret, "EmptyClipboard error %ld\n", GetLastError());
+ ret =CloseClipboard();
+ ok( ret, "CloseClipboard error %ld\n", GetLastError());
if (CountClipboardFormats())
{
--- wine/dlls/user/tests/msg.c 2004-12-20 18:19:20.000000000 +0100
+++ mywine/dlls/user/tests/msg.c 2004-12-22 21:56:04.000000000 +0100
@@ -2168,6 +2168,7 @@ static void test_hv_scroll_1(HWND hwnd,
{
DWORD style, exstyle;
INT xmin, xmax;
+ BOOL ret;
exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
style = GetWindowLongA(hwnd, GWL_STYLE);
@@ -2177,7 +2178,8 @@ static void test_hv_scroll_1(HWND hwnd,
if (clear) ok(style & clear, "style %08lx should be set\n", clear);
if (set) ok(!(style & set), "style %08lx should not be set\n", set);
- ok(SetScrollRange(hwnd, ctl, min, max, FALSE), "SetScrollRange(%d) error %ld\n", ctl, GetLastError());
+ ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
+ ok( ret, "SetScrollRange(%d) error %ld\n", ctl, GetLastError());
if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE);
else
@@ -2188,13 +2190,15 @@ static void test_hv_scroll_1(HWND hwnd,
if (clear) ok(!(style & clear), "style %08lx should not be set\n", clear);
/* a subsequent call should do nothing */
- ok(SetScrollRange(hwnd, ctl, min, max, FALSE), "SetScrollRange(%d) error %ld\n", ctl, GetLastError());
+ ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
+ ok( ret, "SetScrollRange(%d) error %ld\n", ctl, GetLastError());
ok_sequence(WmEmptySeq, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE);
xmin = 0xdeadbeef;
xmax = 0xdeadbeef;
trace("Ignore GetScrollRange error below if you are on Win9x\n");
- ok(GetScrollRange(hwnd, ctl, &xmin, &xmax), "GetScrollRange(%d) error %ld\n", ctl, GetLastError());
+ ret = GetScrollRange(hwnd, ctl, &xmin, &xmax);
+ ok( ret, "GetScrollRange(%d) error %ld\n", ctl, GetLastError());
ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT)", FALSE);
ok(xmin == min, "unexpected min scroll value %d\n", xmin);
ok(xmax == max, "unexpected max scroll value %d\n", xmax);
@@ -2204,6 +2208,7 @@ static void test_hv_scroll_2(HWND hwnd,
{
DWORD style, exstyle;
SCROLLINFO si;
+ BOOL ret;
exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
style = GetWindowLongA(hwnd, GWL_STYLE);
@@ -2244,7 +2249,8 @@ static void test_hv_scroll_2(HWND hwnd,
si.fMask = SIF_RANGE;
si.nMin = 0xdeadbeef;
si.nMax = 0xdeadbeef;
- ok(GetScrollInfo(hwnd, ctl, &si), "GetScrollInfo error %ld\n", GetLastError());
+ ret = GetScrollInfo(hwnd, ctl, &si);
+ ok( ret, "GetScrollInfo error %ld\n", GetLastError());
ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT)", FALSE);
ok(si.nMin == min, "unexpected min scroll value %d\n", si.nMin);
ok(si.nMax == max, "unexpected max scroll value %d\n", si.nMax);
@@ -2255,23 +2261,27 @@ static void test_scroll_messages(HWND hw
{
SCROLLINFO si;
INT min, max;
+ BOOL ret;
min = 0xdeadbeef;
max = 0xdeadbeef;
- ok(GetScrollRange(hwnd, SB_CTL, &min, &max), "GetScrollRange error %ld\n", GetLastError());
+ ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
+ ok( ret, "GetScrollRange error %ld\n", GetLastError());
if (sequence->message != WmGetScrollRangeSeq[0].message)
trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
/* values of min and max are undefined */
flush_sequence();
- ok(SetScrollRange(hwnd, SB_CTL, 10, 150, FALSE), "SetScrollRange error %ld\n", GetLastError());
+ ret = SetScrollRange(hwnd, SB_CTL, 10, 150, FALSE);
+ ok( ret, "SetScrollRange error %ld\n", GetLastError());
if (sequence->message != WmSetScrollRangeSeq[0].message)
trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
flush_sequence();
min = 0xdeadbeef;
max = 0xdeadbeef;
- ok(GetScrollRange(hwnd, SB_CTL, &min, &max), "GetScrollRange error %ld\n", GetLastError());
+ ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
+ ok( ret, "GetScrollRange error %ld\n", GetLastError());
if (sequence->message != WmGetScrollRangeSeq[0].message)
trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
/* values of min and max are undefined */
@@ -2303,7 +2313,8 @@ static void test_scroll_messages(HWND hw
si.fMask = SIF_RANGE;
si.nMin = 0xdeadbeef;
si.nMax = 0xdeadbeef;
- ok(GetScrollInfo(hwnd, SB_CTL, &si), "GetScrollInfo error %ld\n", GetLastError());
+ ret = GetScrollInfo(hwnd, SB_CTL, &si);
+ ok( ret, "GetScrollInfo error %ld\n", GetLastError());
if (sequence->message != WmGetScrollInfoSeq[0].message)
trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
/* values of min and max are undefined */
@@ -3366,6 +3377,7 @@ static void test_interthread_messages(vo
char buf[256];
int len, expected_len;
struct wnd_event wnd_event;
+ BOOL ret;
wnd_event.event = CreateEventW(NULL, 0, 0, NULL);
if (!wnd_event.event)
@@ -3415,7 +3427,8 @@ static void test_interthread_messages(vo
ok(!len && GetLastError() == 0xdeadbeef,
"DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %ld\n", len, GetLastError());
- ok(PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0), "PostMessageA(WM_QUIT) error %ld\n", GetLastError());
+ ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
+ ok( ret, "PostMessageA(WM_QUIT) error %ld\n", GetLastError());
ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
CloseHandle(hThread);
@@ -3549,8 +3562,9 @@ static void test_accelerators(void)
HACCEL hAccel;
HWND hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
100, 100, 200, 200, 0, 0, 0, NULL);
- assert(hwnd != 0);
+ BOOL ret;
+ assert(hwnd != 0);
SetFocus(hwnd);
ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
@@ -3607,7 +3621,8 @@ static void test_accelerators(void)
pump_msg_loop(hwnd, hAccel);
ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 1", FALSE);
- ok(DestroyAcceleratorTable(hAccel), "DestroyAcceleratorTable error %ld\n", GetLastError());
+ ret = DestroyAcceleratorTable(hAccel);
+ ok( ret, "DestroyAcceleratorTable error %ld\n", GetLastError());
hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
assert(hAccel != 0);
@@ -3657,7 +3672,8 @@ static void test_accelerators(void)
pump_msg_loop(hwnd, hAccel);
ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 2", FALSE);
- ok(DestroyAcceleratorTable(hAccel), "DestroyAcceleratorTable error %ld\n", GetLastError());
+ ret = DestroyAcceleratorTable(hAccel);
+ ok( ret, "DestroyAcceleratorTable error %ld\n", GetLastError());
DestroyWindow(hwnd);
}
--- wine/dlls/user/tests/text.c 2004-07-21 00:09:14.000000000 +0200
+++ mywine/dlls/user/tests/text.c 2004-12-22 22:07:18.000000000 +0100
@@ -38,6 +38,7 @@ static void test_DrawTextCalcRect(void)
"MM_HIENGLISH mode";
INT len;
RECT rect = { 0, 0, 100, 0 };
+ BOOL ret;
/* Initialization */
hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
@@ -65,9 +66,10 @@ static void test_DrawTextCalcRect(void)
GetLastError());
hOldFont = SelectObject(hdc, hFont);
- ok(DrawTextA(hdc, text, len, &rect, DT_CALCRECT |
+ len = DrawTextA(hdc, text, len, &rect, DT_CALCRECT |
DT_EXTERNALLEADING | DT_WORDBREAK | DT_NOCLIP | DT_LEFT |
- DT_NOPREFIX),"DrawTextA error %lu\n", GetLastError());
+ DT_NOPREFIX);
+ ok( len, "DrawTextA error %lu\n", GetLastError());
trace("MM_HIENGLISH rect.bottom %ld\n", rect.bottom);
todo_wine ok(rect.bottom < 0, "In MM_HIENGLISH, DrawText with "
@@ -75,8 +77,8 @@ static void test_DrawTextCalcRect(void)
"(bot=%ld)\n", rect.bottom);
SelectObject(hdc, hOldFont);
- ok(DeleteObject(hFont), "DeleteObject error %lu\n",
- GetLastError());
+ ret = DeleteObject(hFont);
+ ok( ret, "DeleteObject error %lu\n", GetLastError());
/* DrawText in MM_TEXT with DT_CALCRECT */
@@ -88,9 +90,10 @@ static void test_DrawTextCalcRect(void)
GetLastError());
hOldFont = SelectObject(hdc, hFont);
- ok(DrawTextA(hdc, text, len, &rect, DT_CALCRECT |
+ len = DrawTextA(hdc, text, len, &rect, DT_CALCRECT |
DT_EXTERNALLEADING | DT_WORDBREAK | DT_NOCLIP | DT_LEFT |
- DT_NOPREFIX),"DrawTextA error %lu\n", GetLastError());
+ DT_NOPREFIX);
+ ok( len, "DrawTextA error %lu\n", GetLastError());
trace("MM_TEXT rect.bottom %ld\n", rect.bottom);
ok(rect.bottom > 0, "In MM_TEXT, DrawText with DT_CALCRECT "
@@ -98,14 +101,14 @@ static void test_DrawTextCalcRect(void)
rect.bottom);
SelectObject(hdc, hOldFont);
- ok(DeleteObject(hFont), "DeleteObject error %lu\n",
- GetLastError());
+ ret = DeleteObject(hFont);
+ ok( ret, "DeleteObject error %lu\n", GetLastError());
/* Clean up */
- ok(ReleaseDC(hwnd, hdc), "ReleaseDC error %lu\n",
- GetLastError());
- ok(DestroyWindow(hwnd), "DestroyWindow error %lu\n",
- GetLastError());
+ ret = ReleaseDC(hwnd, hdc);
+ ok( ret, "ReleaseDC error %lu\n", GetLastError());
+ ret = DestroyWindow(hwnd);
+ ok( ret, "DestroyWindow error %lu\n", GetLastError());
}
START_TEST(text)
--- wine/dlls/user/tests/win.c 2004-12-22 09:40:25.000000000 +0100
+++ mywine/dlls/user/tests/win.c 2004-12-23 13:15:21.000000000 +0100
@@ -1672,6 +1672,7 @@ static void test_SetMenu(HWND parent)
HWND child;
HMENU hMenu, ret;
BOOL is_win9x = GetWindowLongW(parent, GWL_WNDPROC) == 0;
+ BOOL retok;
hMenu = CreateMenu();
assert(hMenu);
@@ -1681,7 +1682,8 @@ static void test_SetMenu(HWND parent)
ret = GetMenu(parent);
ok(ret == hMenu, "unexpected menu id %p\n", ret);
/* test whether we can destroy a menu assigned to a window */
- ok(DestroyMenu(hMenu), "DestroyMenu error %ld\n", GetLastError());
+ retok = DestroyMenu(hMenu);
+ ok( retok, "DestroyMenu error %ld\n", GetLastError());
ok(!IsMenu(hMenu), "menu handle should be not valid after DestroyMenu\n");
ret = GetMenu(parent);
/* This test fails on Win9x */
@@ -2050,6 +2052,7 @@ static void test_capture_3(HWND hwnd1, H
static void test_keyboard_input(HWND hwnd)
{
MSG msg;
+ BOOL ret;
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
@@ -2064,21 +2067,24 @@ static void test_keyboard_input(HWND hwn
PostMessageA(hwnd, WM_KEYDOWN, 0, 0);
ok(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "no message available\n");
ok(msg.hwnd == hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
- ok(!PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "message %04x available\n", msg.message);
+ ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
+ ok( !ret, "message %04x available\n", msg.message);
ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN, 0, 0);
ok(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "no message available\n");
ok(!msg.hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
- ok(!PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "message %04x available\n", msg.message);
+ ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
+ ok( !ret, "message %04x available\n", msg.message);
ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
keybd_event(VK_SPACE, 0, 0, 0);
ok(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "no message available\n");
ok(msg.hwnd == hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
- ok(!PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "message %04x available\n", msg.message);
+ ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
+ ok( !ret, "message %04x available\n", msg.message);
SetFocus(0);
ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
@@ -2088,21 +2094,24 @@ static void test_keyboard_input(HWND hwn
PostMessageA(hwnd, WM_KEYDOWN, 0, 0);
ok(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "no message available\n");
ok(msg.hwnd == hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
- ok(!PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "message %04x available\n", msg.message);
+ ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
+ ok( !ret, "message %04x available\n", msg.message);
ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN, 0, 0);
ok(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "no message available\n");
ok(!msg.hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
- ok(!PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "message %04x available\n", msg.message);
+ ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
+ ok( !ret, "message %04x available\n", msg.message);
ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
keybd_event(VK_SPACE, 0, 0, 0);
ok(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "no message available\n");
ok(msg.hwnd == hwnd && msg.message == WM_SYSKEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
- ok(!PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "message %04x available\n", msg.message);
+ ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
+ ok( !ret, "message %04x available\n", msg.message);
}
static void test_mouse_input(HWND hwnd)
@@ -2112,6 +2121,7 @@ static void test_mouse_input(HWND hwnd)
int x, y;
HWND popup;
MSG msg;
+ BOOL ret;
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
@@ -2150,7 +2160,8 @@ static void test_mouse_input(HWND hwnd)
/* FIXME: SetCursorPos in Wine generates additional WM_MOUSEMOVE message */
if (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
ok(msg.hwnd == popup && msg.message == WM_MOUSEMOVE, "hwnd %p message %04x\n", msg.hwnd, msg.message);
- ok(!PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "message %04x available\n", msg.message);
+ ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
+ ok( !ret, "message %04x available\n", msg.message);
mouse_event(MOUSEEVENTF_MOVE, -1, -1, 0, 0);
ShowWindow(popup, SW_HIDE);
@@ -2160,7 +2171,8 @@ static void test_mouse_input(HWND hwnd)
mouse_event(MOUSEEVENTF_MOVE, 1, 1, 0, 0);
ShowWindow(hwnd, SW_HIDE);
- ok(!PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "message %04x available\n", msg.message);
+ ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
+ ok( !ret, "message %04x available\n", msg.message);
DestroyWindow(popup);
}
More information about the wine-patches
mailing list