[INCLUDES/WINE] Update test.h.
[reactos.git] / reactos / sdk / include / reactos / wine / test.h
1 /*
2 * Definitions for Wine C unit tests.
3 *
4 * Copyright (C) 2002 Alexandre Julliard
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #ifndef __WINE_WINE_TEST_H
22 #define __WINE_WINE_TEST_H
23
24 #include <stdarg.h>
25 #include <stdlib.h>
26 #include <windef.h>
27 #include <winbase.h>
28
29 #ifdef __WINE_CONFIG_H
30 #error config.h should not be used in Wine tests
31 #endif
32 #ifdef __WINE_WINE_LIBRARY_H
33 #error wine/library.h should not be used in Wine tests
34 #endif
35 #ifdef __WINE_WINE_UNICODE_H
36 #error wine/unicode.h should not be used in Wine tests
37 #endif
38 #ifdef __WINE_WINE_DEBUG_H
39 #error wine/debug.h should not be used in Wine tests
40 #endif
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 #ifndef INVALID_FILE_ATTRIBUTES
47 #define INVALID_FILE_ATTRIBUTES (~0u)
48 #endif
49 #ifndef INVALID_SET_FILE_POINTER
50 #define INVALID_SET_FILE_POINTER (~0u)
51 #endif
52
53 /* debug level */
54 extern int winetest_debug;
55
56 /* running in interactive mode? */
57 extern int winetest_interactive;
58
59 /* current platform */
60 extern const char *winetest_platform;
61
62 extern void winetest_set_location( const char* file, int line );
63 extern void winetest_start_todo( int is_todo );
64 extern int winetest_loop_todo(void);
65 extern void winetest_end_todo(void);
66 extern int winetest_get_mainargs( char*** pargv );
67 extern LONG winetest_get_failures(void);
68 extern void winetest_add_failures( LONG new_failures );
69 extern void winetest_wait_child_process( HANDLE process );
70
71 extern const char *wine_dbgstr_wn( const WCHAR *str, intptr_t n );
72 extern const char *wine_dbgstr_guid( const GUID *guid );
73 extern const char *wine_dbgstr_rect( const RECT *rect );
74 static inline const char *wine_dbgstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
75
76 /* strcmpW is available for tests compiled under Wine, but not in standalone
77 * builds under Windows, so we reimplement it under a different name. */
78 static inline int winetest_strcmpW( const WCHAR *str1, const WCHAR *str2 )
79 {
80 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
81 return *str1 - *str2;
82 }
83
84 #ifdef STANDALONE
85
86 #define START_TEST(name) \
87 static void func_##name(void); \
88 const struct test winetest_testlist[] = { { #name, func_##name }, { 0, 0 } }; \
89 static void func_##name(void)
90
91 #else /* STANDALONE */
92
93 #ifdef __cplusplus
94 #define START_TEST(name) extern "C" void func_##name(void)
95 #else
96 #define START_TEST(name) void func_##name(void)
97 #endif
98
99 #endif /* STANDALONE */
100
101 #if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
102 #define __winetest_cdecl __cdecl
103 #define __winetest_va_list __builtin_ms_va_list
104 #else
105 #define __winetest_cdecl
106 #define __winetest_va_list va_list
107 #endif
108
109 extern int broken( int condition );
110 extern int winetest_vok( int condition, const char *msg, __winetest_va_list ap );
111 extern void winetest_vskip( const char *msg, __winetest_va_list ap );
112
113 #ifdef __GNUC__
114 # define WINETEST_PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
115 extern void __winetest_cdecl winetest_ok( int condition, const char *msg, ... ) __attribute__((format (printf,2,3) ));
116 extern void __winetest_cdecl winetest_skip( const char *msg, ... ) __attribute__((format (printf,1,2)));
117 extern void __winetest_cdecl winetest_win_skip( const char *msg, ... ) __attribute__((format (printf,1,2)));
118 extern void __winetest_cdecl winetest_trace( const char *msg, ... ) __attribute__((format (printf,1,2)));
119
120 #else /* __GNUC__ */
121 # define WINETEST_PRINTF_ATTR(fmt,args)
122 extern void __winetest_cdecl winetest_ok( int condition, const char *msg, ... );
123 extern void __winetest_cdecl winetest_skip( const char *msg, ... );
124 extern void __winetest_cdecl winetest_win_skip( const char *msg, ... );
125 extern void __winetest_cdecl winetest_trace( const char *msg, ... );
126
127 #endif /* __GNUC__ */
128
129 #define ok_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_ok
130 #define skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_skip
131 #define win_skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_win_skip
132 #define trace_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_trace
133
134 #define ok ok_(__FILE__, __LINE__)
135 #define skip skip_(__FILE__, __LINE__)
136 #define win_skip win_skip_(__FILE__, __LINE__)
137 #define trace trace_(__FILE__, __LINE__)
138
139 #define todo_if(is_todo) for (winetest_start_todo(is_todo); \
140 winetest_loop_todo(); \
141 winetest_end_todo())
142
143 #define todo_ros todo_if(!strcmp(winetest_platform, "reactos"))
144 #define todo_ros_if(is_todo) todo_if((is_todo) && !strcmp(winetest_platform, "reactos"))
145 #ifdef USE_WINE_TODOS
146 #define todo_wine todo_ros
147 #define todo_wine_if todo_ros_if
148 #else
149 #define todo_wine todo_if(!strcmp(winetest_platform, "wine"))
150 #define todo_wine_if(is_todo) todo_if((is_todo) && !strcmp(winetest_platform, "wine"))
151 #endif
152
153
154 #ifdef NONAMELESSUNION
155 # define U(x) (x).u
156 # define U1(x) (x).u1
157 # define U2(x) (x).u2
158 # define U3(x) (x).u3
159 # define U4(x) (x).u4
160 # define U5(x) (x).u5
161 # define U6(x) (x).u6
162 # define U7(x) (x).u7
163 # define U8(x) (x).u8
164 #else
165 # define U(x) (x)
166 # define U1(x) (x)
167 # define U2(x) (x)
168 # define U3(x) (x)
169 # define U4(x) (x)
170 # define U5(x) (x)
171 # define U6(x) (x)
172 # define U7(x) (x)
173 # define U8(x) (x)
174 #endif
175
176 #ifdef NONAMELESSSTRUCT
177 # define S(x) (x).s
178 # define S1(x) (x).s1
179 # define S2(x) (x).s2
180 # define S3(x) (x).s3
181 # define S4(x) (x).s4
182 # define S5(x) (x).s5
183 #else
184 # define S(x) (x)
185 # define S1(x) (x)
186 # define S2(x) (x)
187 # define S3(x) (x)
188 # define S4(x) (x)
189 # define S5(x) (x)
190 #endif
191
192
193 /************************************************************************/
194 /* Below is the implementation of the various functions, to be included
195 * directly into the generated testlist.c file.
196 * It is done that way so that the dlls can build the test routines with
197 * different includes or flags if needed.
198 */
199
200 #ifdef STANDALONE
201
202 #include <stdio.h>
203
204 #if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
205 # define __winetest_va_start(list,arg) __builtin_ms_va_start(list,arg)
206 # define __winetest_va_end(list) __builtin_ms_va_end(list)
207 #else
208 # define __winetest_va_start(list,arg) va_start(list,arg)
209 # define __winetest_va_end(list) va_end(list)
210 #endif
211
212 /* Define WINETEST_MSVC_IDE_FORMATTING to alter the output format winetest will use for file/line numbers.
213 This alternate format makes the file/line numbers clickable in visual studio, to directly jump to them. */
214 #if defined(WINETEST_MSVC_IDE_FORMATTING)
215 # define __winetest_file_line_prefix "%s(%d)"
216 #else
217 # define __winetest_file_line_prefix "%s:%d"
218 #endif
219
220 struct test
221 {
222 const char *name;
223 void (*func)(void);
224 };
225
226 extern const struct test winetest_testlist[];
227
228 /* debug level */
229 int winetest_debug = 1;
230
231 /* interactive mode? */
232 int winetest_interactive = 0;
233
234 /* current platform */
235 const char *winetest_platform = "windows";
236
237 /* report successful tests (BOOL) */
238 static int report_success = 0;
239
240 /* passing arguments around */
241 static int winetest_argc;
242 static char** winetest_argv;
243
244 static const struct test *current_test; /* test currently being run */
245
246 static LONG successes; /* number of successful tests */
247 static LONG failures; /* number of failures */
248 static LONG skipped; /* number of skipped test chunks */
249 static LONG todo_successes; /* number of successful tests inside todo block */
250 static LONG todo_failures; /* number of failures inside todo block */
251
252 /* The following data must be kept track of on a per-thread basis */
253 typedef struct
254 {
255 const char* current_file; /* file of current check */
256 int current_line; /* line of current check */
257 unsigned int todo_level; /* current todo nesting level */
258 int todo_do_loop;
259 char *str_pos; /* position in debug buffer */
260 char strings[2000]; /* buffer for debug strings */
261 } tls_data;
262 static DWORD tls_index;
263
264 static tls_data* get_tls_data(void)
265 {
266 tls_data* data;
267 DWORD last_error;
268
269 last_error=GetLastError();
270 data=(tls_data*)TlsGetValue(tls_index);
271 if (!data)
272 {
273 data=(tls_data*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(tls_data));
274 data->str_pos = data->strings;
275 TlsSetValue(tls_index,data);
276 }
277 SetLastError(last_error);
278 return data;
279 }
280
281 /* allocate some tmp space for a string */
282 static char *get_temp_buffer( size_t n )
283 {
284 tls_data *data = get_tls_data();
285 char *res = data->str_pos;
286
287 if (res + n >= &data->strings[sizeof(data->strings)]) res = data->strings;
288 data->str_pos = res + n;
289 return res;
290 }
291
292 /* release extra space that we requested in gimme1() */
293 static void release_temp_buffer( char *ptr, size_t size )
294 {
295 tls_data *data = get_tls_data();
296 data->str_pos = ptr + size;
297 }
298
299 static void exit_process( int code )
300 {
301 fflush( stdout );
302 ExitProcess( code );
303 }
304
305
306 void winetest_set_location( const char* file, int line )
307 {
308 tls_data* data=get_tls_data();
309 #if defined(WINETEST_MSVC_IDE_FORMATTING)
310 data->current_file = file;
311 #else
312 data->current_file=strrchr(file,'/');
313 if (data->current_file==NULL)
314 data->current_file=strrchr(file,'\\');
315 if (data->current_file==NULL)
316 data->current_file=file;
317 else
318 data->current_file++;
319 #endif
320 data->current_line=line;
321 }
322
323 int broken( int condition )
324 {
325 return ((strcmp(winetest_platform, "windows") == 0)
326 #ifndef USE_WINE_TODOS
327 || (strcmp(winetest_platform, "reactos") == 0)
328 #endif
329 ) && condition;
330 }
331
332 /*
333 * Checks condition.
334 * Parameters:
335 * - condition - condition to check;
336 * - msg test description;
337 * - file - test application source code file name of the check
338 * - line - test application source code file line number of the check
339 * Return:
340 * 0 if condition does not have the expected value, 1 otherwise
341 */
342 int winetest_vok( int condition, const char *msg, __winetest_va_list args )
343 {
344 tls_data* data=get_tls_data();
345
346 if (data->todo_level)
347 {
348 if (condition)
349 {
350 fprintf( stdout, __winetest_file_line_prefix ": Test succeeded inside todo block: ",
351 data->current_file, data->current_line );
352 vfprintf(stdout, msg, args);
353 InterlockedIncrement(&todo_failures);
354 return 0;
355 }
356 else
357 {
358 /* show todos even if traces are disabled*/
359 /*if (winetest_debug > 0)*/
360 {
361 fprintf( stdout, __winetest_file_line_prefix ": Test marked todo: ",
362 data->current_file, data->current_line );
363 vfprintf(stdout, msg, args);
364 }
365 InterlockedIncrement(&todo_successes);
366 return 1;
367 }
368 }
369 else
370 {
371 if (!condition)
372 {
373 fprintf( stdout, __winetest_file_line_prefix ": Test failed: ",
374 data->current_file, data->current_line );
375 vfprintf(stdout, msg, args);
376 InterlockedIncrement(&failures);
377 return 0;
378 }
379 else
380 {
381 if (report_success)
382 fprintf( stdout, __winetest_file_line_prefix ": Test succeeded\n",
383 data->current_file, data->current_line);
384 InterlockedIncrement(&successes);
385 return 1;
386 }
387 }
388 }
389
390 void __winetest_cdecl winetest_ok( int condition, const char *msg, ... )
391 {
392 __winetest_va_list valist;
393
394 __winetest_va_start(valist, msg);
395 winetest_vok(condition, msg, valist);
396 __winetest_va_end(valist);
397 }
398
399 void __winetest_cdecl winetest_trace( const char *msg, ... )
400 {
401 __winetest_va_list valist;
402 tls_data* data=get_tls_data();
403
404 if (winetest_debug > 0)
405 {
406 fprintf( stdout, __winetest_file_line_prefix ": ", data->current_file, data->current_line );
407 __winetest_va_start(valist, msg);
408 vfprintf(stdout, msg, valist);
409 __winetest_va_end(valist);
410 }
411 }
412
413 void winetest_vskip( const char *msg, __winetest_va_list args )
414 {
415 tls_data* data=get_tls_data();
416
417 fprintf( stdout, __winetest_file_line_prefix ": Tests skipped: ", data->current_file, data->current_line );
418 vfprintf(stdout, msg, args);
419 skipped++;
420 }
421
422 void __winetest_cdecl winetest_skip( const char *msg, ... )
423 {
424 __winetest_va_list valist;
425 __winetest_va_start(valist, msg);
426 winetest_vskip(msg, valist);
427 __winetest_va_end(valist);
428 }
429
430 void __winetest_cdecl winetest_win_skip( const char *msg, ... )
431 {
432 __winetest_va_list valist;
433 __winetest_va_start(valist, msg);
434 if ((strcmp(winetest_platform, "windows") == 0)
435 #ifndef USE_WINE_TODOS
436 || (strcmp(winetest_platform, "reactos") == 0)
437 #endif
438 )
439 winetest_vskip(msg, valist);
440 else
441 winetest_vok(0, msg, valist);
442 __winetest_va_end(valist);
443 }
444
445 void winetest_start_todo( int is_todo )
446 {
447 tls_data* data=get_tls_data();
448 data->todo_level = (data->todo_level << 1) | (is_todo != 0);
449 data->todo_do_loop=1;
450 }
451
452 int winetest_loop_todo(void)
453 {
454 tls_data* data=get_tls_data();
455 int do_loop=data->todo_do_loop;
456 data->todo_do_loop=0;
457 return do_loop;
458 }
459
460 void winetest_end_todo(void)
461 {
462 tls_data* data=get_tls_data();
463 data->todo_level >>= 1;
464 }
465
466 int winetest_get_mainargs( char*** pargv )
467 {
468 *pargv = winetest_argv;
469 return winetest_argc;
470 }
471
472 LONG winetest_get_failures(void)
473 {
474 return failures;
475 }
476
477 void winetest_add_failures( LONG new_failures )
478 {
479 while (new_failures-- > 0)
480 InterlockedIncrement( &failures );
481 }
482
483 void winetest_wait_child_process( HANDLE process )
484 {
485 DWORD exit_code = 1;
486
487 if (WaitForSingleObject( process, 30000 ))
488 fprintf( stdout, "%s: child process wait failed\n", current_test->name );
489 else
490 GetExitCodeProcess( process, &exit_code );
491
492 if (exit_code)
493 {
494 if (exit_code > 255)
495 {
496 fprintf( stdout, "%s: exception 0x%08x in child process\n", current_test->name, (unsigned)exit_code );
497 InterlockedIncrement( &failures );
498 }
499 else
500 {
501 fprintf( stdout, "%s: %u failures in child process\n",
502 current_test->name, (unsigned)exit_code );
503 while (exit_code-- > 0)
504 InterlockedIncrement(&failures);
505 }
506 }
507 }
508
509 const char *wine_dbgstr_wn( const WCHAR *str, intptr_t n )
510 {
511 char *dst, *res;
512 size_t size;
513
514 if (!((ULONG_PTR)str >> 16))
515 {
516 if (!str) return "(null)";
517 res = get_temp_buffer( 6 );
518 sprintf( res, "#%04x", LOWORD(str) );
519 return res;
520 }
521 if (n == -1)
522 {
523 const WCHAR *end = str;
524 while (*end) end++;
525 n = end - str;
526 }
527 if (n < 0) n = 0;
528 size = 12 + min( 300, n * 5 );
529 dst = res = get_temp_buffer( size );
530 *dst++ = 'L';
531 *dst++ = '"';
532 while (n-- > 0 && dst <= res + size - 10)
533 {
534 WCHAR c = *str++;
535 switch (c)
536 {
537 case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
538 case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
539 case '\t': *dst++ = '\\'; *dst++ = 't'; break;
540 case '"': *dst++ = '\\'; *dst++ = '"'; break;
541 case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
542 default:
543 if (c >= ' ' && c <= 126)
544 *dst++ = (char)c;
545 else
546 {
547 *dst++ = '\\';
548 sprintf(dst,"%04x",c);
549 dst+=4;
550 }
551 }
552 }
553 *dst++ = '"';
554 if (n > 0)
555 {
556 *dst++ = '.';
557 *dst++ = '.';
558 *dst++ = '.';
559 }
560 *dst++ = 0;
561 release_temp_buffer( res, dst - res );
562 return res;
563 }
564
565 const char *wine_dbgstr_guid( const GUID *guid )
566 {
567 char *res;
568
569 if (!guid) return "(null)";
570 res = get_temp_buffer( 39 ); /* CHARS_IN_GUID */
571 sprintf( res, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
572 guid->Data1, guid->Data2, guid->Data3, guid->Data4[0],
573 guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4],
574 guid->Data4[5], guid->Data4[6], guid->Data4[7] );
575 return res;
576 }
577
578 const char *wine_dbgstr_rect( const RECT *rect )
579 {
580 char *res;
581
582 if (!rect) return "(null)";
583 res = get_temp_buffer( 60 );
584 #ifdef __ROS_LONG64__
585 sprintf( res, "(%d,%d)-(%d,%d)", rect->left, rect->top, rect->right, rect->bottom );
586 #else
587 sprintf( res, "(%ld,%ld)-(%ld,%ld)", rect->left, rect->top, rect->right, rect->bottom );
588 #endif
589 release_temp_buffer( res, strlen(res) + 1 );
590 return res;
591 }
592
593 /* Find a test by name */
594 static const struct test *find_test( const char *name )
595 {
596 const struct test *test;
597 const char *p;
598 size_t len;
599
600 if ((p = strrchr( name, '/' ))) name = p + 1;
601 if ((p = strrchr( name, '\\' ))) name = p + 1;
602 len = strlen(name);
603 if (len > 2 && !strcmp( name + len - 2, ".c" )) len -= 2;
604
605 for (test = winetest_testlist; test->name; test++)
606 {
607 if (!strncmp( test->name, name, len ) && !test->name[len]) break;
608 }
609 return test->name ? test : NULL;
610 }
611
612
613 /* Display list of valid tests */
614 static void list_tests(void)
615 {
616 const struct test *test;
617
618 fprintf( stdout, "Valid test names:\n" );
619 for (test = winetest_testlist; test->name; test++) fprintf( stdout, " %s\n", test->name );
620 }
621
622 /* Disable false-positive claiming "test" would be NULL-dereferenced */
623 #if defined(_MSC_VER)
624 #pragma warning(push)
625 #pragma warning(disable:28182)
626 #endif
627
628 /* Run a named test, and return exit status */
629 static int run_test( const char *name )
630 {
631 const struct test *test;
632 int status;
633
634 if (!(test = find_test( name )))
635 {
636 fprintf( stdout, "Fatal: test '%s' does not exist.\n", name );
637 exit_process(1);
638 }
639 successes = failures = todo_successes = todo_failures = 0;
640 tls_index=TlsAlloc();
641 current_test = test;
642 test->func();
643
644 /* show test results even if traces are disabled */
645 /*if (winetest_debug)*/
646 {
647 fprintf( stdout, "\n%s: %d tests executed (%d marked as todo, %d %s), %d skipped.\n",
648 test->name, (int)(successes + failures + todo_successes + todo_failures),
649 (int)todo_successes, (int)(failures + todo_failures),
650 (failures + todo_failures != 1) ? "failures" : "failure",
651 (int)skipped );
652 }
653 status = (failures + todo_failures < 255) ? failures + todo_failures : 255;
654 return status;
655 }
656
657 #if defined(_MSC_VER)
658 #pragma warning(pop)
659 #endif
660
661 /* Display usage and exit */
662 static void usage( const char *argv0 )
663 {
664 fprintf( stdout, "Usage: %s test_name\n\n", argv0 );
665 list_tests();
666 exit_process(1);
667 }
668
669
670 /* main function */
671 int main( int argc, char **argv )
672 {
673 char p[128];
674
675 setvbuf (stdout, NULL, _IONBF, 0);
676
677 winetest_argc = argc;
678 winetest_argv = argv;
679
680 if (GetEnvironmentVariableA( "WINETEST_PLATFORM", p, sizeof(p) )) winetest_platform = _strdup(p);
681 if (GetEnvironmentVariableA( "WINETEST_DEBUG", p, sizeof(p) )) winetest_debug = atoi(p);
682 if (GetEnvironmentVariableA( "WINETEST_INTERACTIVE", p, sizeof(p) )) winetest_interactive = atoi(p);
683 if (GetEnvironmentVariableA( "WINETEST_REPORT_SUCCESS", p, sizeof(p) )) report_success = atoi(p);
684
685 if (!winetest_interactive) SetErrorMode( SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX );
686
687 if (!argv[1])
688 {
689 if (winetest_testlist[0].name && !winetest_testlist[1].name) /* only one test */
690 return run_test( winetest_testlist[0].name );
691 usage( argv[0] );
692 }
693 if (!strcmp( argv[1], "--list" ))
694 {
695 list_tests();
696 return 0;
697 }
698 return run_test(argv[1]);
699 }
700
701 #endif /* STANDALONE */
702
703 // hack for ntdll winetest (this is defined in excpt.h)
704 #undef exception_info
705
706 // Some helpful definitions
707
708 #define ok_hex(expression, result) \
709 do { \
710 int _value = (expression); \
711 ok(_value == (result), "Wrong value for '%s', expected: " #result " (0x%x), got: 0x%x\n", \
712 #expression, (int)(result), _value); \
713 } while (0)
714
715 #define ok_dec(expression, result) \
716 do { \
717 int _value = (expression); \
718 ok(_value == (result), "Wrong value for '%s', expected: " #result " (%d), got: %d\n", \
719 #expression, (int)(result), _value); \
720 } while (0)
721
722 #define ok_ptr(expression, result) \
723 do { \
724 void *_value = (expression); \
725 ok(_value == (result), "Wrong value for '%s', expected: " #result " (%p), got: %p\n", \
726 #expression, (void*)(result), _value); \
727 } while (0)
728
729 #define ok_size_t(expression, result) \
730 do { \
731 size_t _value = (expression); \
732 ok(_value == (result), "Wrong value for '%s', expected: " #result " (%Ix), got: %Ix\n", \
733 #expression, (size_t)(result), _value); \
734 } while (0)
735
736 #define ok_char(expression, result) ok_hex(expression, result)
737
738 #define ok_err(error) \
739 ok(GetLastError() == (error), "Wrong last error. Expected " #error ", got 0x%lx\n", GetLastError())
740
741 #define ok_str(x, y) \
742 ok(strcmp(x, y) == 0, "Wrong string. Expected '%s', got '%s'\n", y, x)
743
744 #define ok_wstr(x, y) \
745 ok(wcscmp(x, y) == 0, "Wrong string. Expected '%S', got '%S'\n", y, x)
746
747 #define ok_long(expression, result) ok_hex(expression, result)
748 #define ok_int(expression, result) ok_dec(expression, result)
749 #define ok_ntstatus(status, expected) ok_hex(status, expected)
750 #define ok_hdl ok_ptr
751
752 #ifdef __cplusplus
753 } /* extern "C" */
754 #endif
755
756 #endif /* __WINE_WINE_TEST_H */