ReactOS  0.4.13-dev-1148-g9b75b67
atltest.h
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS api tests
3  * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4  * PURPOSE: Testing
5  * COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6  */
7 
8 #ifndef ATLTEST_H_
9 #define ATLTEST_H_
10 
11 #include <stdlib.h>
12 #include <stdio.h>
13 #include <stdarg.h>
14 #include <string.h>
15 #ifndef _INC_WINDOWS
16  #include <windows.h>
17 #endif
18 
22 
23 const char *g_atltest_file = NULL;
25 
26 void atltest_set_location(const char *file, int line)
27 {
30 }
31 
32 void atltest_ok(int value, const char *fmt, ...)
33 {
34  va_list va;
35  va_start(va, fmt);
36  if (!value)
37  {
38  printf("%s (%d): ", g_atltest_file, g_atltest_line);
39  vprintf(fmt, va);
41  }
43  va_end(va);
44 }
45 
46 void atltest_skip(const char *fmt, ...)
47 {
48  va_list va;
49  va_start(va, fmt);
50  printf("%s (%d): test skipped: ", g_atltest_file, g_atltest_line);
51  vprintf(fmt, va);
53  va_end(va);
54 }
55 
56 #undef ok
57 #define ok(value, ...) do { \
58  atltest_set_location(__FILE__, __LINE__); \
59  atltest_ok(value, __VA_ARGS__); \
60 } while (0)
61 #define ok_(x1,x2) atltest_set_location(x1,x2); atltest_ok
62 
63 #undef skip
64 #define skip(...) do { \
65  atltest_set_location(__FILE__, __LINE__); \
66  atltest_skip(__VA_ARGS__); \
67 } while (0)
68 
69 #undef trace
70 #define trace printf
71 
72 static void atltest_start_test(void);
73 extern const char *g_atltest_name;
74 
75 #define START_TEST(x) \
76  const char *g_atltest_name = #x; \
77  static void atltest_start_test(void)
78 
79 int main(void)
80 {
82  printf("%s: %d tests executed (0 marked as todo, %d failures), %d skipped.\n",
84  return g_atltest_failed;
85 }
86 
87 char *wine_dbgstr_w(const wchar_t *wstr)
88 {
89  static char buf[512];
90  WideCharToMultiByte(CP_ACP, 0, wstr, -1, buf, _countof(buf), NULL, NULL);
91  return buf;
92 }
93 
94 #define ok_hex(expression, result) \
95  do { \
96  int _value = (expression); \
97  ok(_value == (result), "Wrong value for '%s', expected: " #result " (0x%x), got: 0x%x\n", \
98  #expression, (int)(result), _value); \
99  } while (0)
100 
101 #define ok_dec(expression, result) \
102  do { \
103  int _value = (expression); \
104  ok(_value == (result), "Wrong value for '%s', expected: " #result " (%d), got: %d\n", \
105  #expression, (int)(result), _value); \
106  } while (0)
107 
108 #define ok_ptr(expression, result) \
109  do { \
110  void *_value = (expression); \
111  ok(_value == (result), "Wrong value for '%s', expected: " #result " (%p), got: %p\n", \
112  #expression, (void*)(result), _value); \
113  } while (0)
114 
115 #define ok_size_t(expression, result) \
116  do { \
117  size_t _value = (expression); \
118  ok(_value == (result), "Wrong value for '%s', expected: " #result " (%Ix), got: %Ix\n", \
119  #expression, (size_t)(result), _value); \
120  } while (0)
121 
122 #define ok_char(expression, result) ok_hex(expression, result)
123 
124 #define ok_err(error) \
125  ok(GetLastError() == (error), "Wrong last error. Expected " #error ", got 0x%lx\n", GetLastError())
126 
127 #define ok_str(x, y) \
128  ok(strcmp(x, y) == 0, "Wrong string. Expected '%s', got '%s'\n", y, x)
129 
130 #define ok_wstr(x, y) \
131  ok(wcscmp(x, y) == 0, "Wrong string. Expected '%S', got '%S'\n", y, x)
132 
133 #define ok_long(expression, result) ok_hex(expression, result)
134 #define ok_int(expression, result) ok_dec(expression, result)
135 #define ok_ntstatus(status, expected) ok_hex(status, expected)
136 #define ok_hdl ok_ptr
137 
138 #endif /* ndef ATLTEST_H_ */
#define WideCharToMultiByte
Definition: compat.h:101
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
#define CP_ACP
Definition: compat.h:99
#define _countof(array)
Definition: fontsub.cpp:30
#define va_end(ap)
Definition: acmsvcex.h:90
int g_atltest_line
Definition: atltest.h:24
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
char * va_list
Definition: acmsvcex.h:78
void atltest_ok(int value, const char *fmt,...)
Definition: atltest.h:32
int main(void)
Definition: atltest.h:79
_Check_return_opt_ _CRTIMP int __cdecl vprintf(_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
const char file[]
Definition: icontest.c:11
const char * g_atltest_file
Definition: atltest.h:23
char line[200]
Definition: main.c:97
int g_atltest_executed
Definition: atltest.h:19
static void atltest_start_test(void)
int g_atltest_skipped
Definition: atltest.h:21
#define va_start(ap, A)
Definition: acmsvcex.h:91
void atltest_skip(const char *fmt,...)
Definition: atltest.h:46
void atltest_set_location(const char *file, int line)
Definition: atltest.h:26
int g_atltest_failed
Definition: atltest.h:20
const char * g_atltest_name
Definition: dsound.c:943
#define printf
Definition: config.h:203
Definition: fci.c:126