ReactOS 0.4.16-dev-340-g0540c21
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-2023 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
23const char *g_atltest_file = NULL;
25
26void atltest_set_location(const char *file, int line)
27{
30}
31
32void atltest_ok(int value, const char *fmt, ...)
33{
34 va_list va;
35 va_start(va, fmt);
36 if (!value)
37 {
39 vprintf(fmt, va);
41 }
43 va_end(va);
44}
45
46void 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
72static void atltest_start_test(void);
73extern 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
79int 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
87char *wine_dbgstr_w(const wchar_t *wstr)
88{
89 static char buf[512];
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 const 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
138static inline const char *wine_dbgstr_point(const POINT *ppt)
139{
140 static char s_asz[4][40]; /* Ring buffer */
141 static int s_i = 0;
142 char *buf;
143
144 if (!ppt)
145 return "(null)";
146 if (IS_INTRESOURCE(ppt))
147 return "(invalid ptr)";
148
149 buf = s_asz[s_i];
150 s_i = (s_i + 1) % _countof(s_asz);
151 sprintf_s(buf, _countof(s_asz[0]), "(%ld, %ld)", ppt->x, ppt->y);
152 return buf;
153}
154
155static inline const char *wine_dbgstr_size(const SIZE *psize)
156{
157 return wine_dbgstr_point((const POINT *)psize);
158}
159
160static inline const char *wine_dbgstr_rect(const RECT *prc)
161{
162 static char s_asz[4][80]; /* Ring buffer */
163 static int s_i = 0;
164 char *buf;
165
166 if (!prc)
167 return "(null)";
168 if (IS_INTRESOURCE(prc))
169 return "(invalid ptr)";
170
171 buf = s_asz[s_i];
172 s_i = (s_i + 1) % _countof(s_asz);
173 sprintf_s(buf, _countof(s_asz[0]), "(%ld, %ld) - (%ld, %ld)",
174 prc->left, prc->top, prc->right, prc->bottom);
175 return buf;
176}
177
178#define broken(x) x
179
180#endif /* ndef ATLTEST_H_ */
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
static const char * wine_dbgstr_point(const POINT *ppt)
Definition: atltest.h:138
static void atltest_start_test(void)
int g_atltest_executed
Definition: atltest.h:19
void atltest_set_location(const char *file, int line)
Definition: atltest.h:26
static const char * wine_dbgstr_size(const SIZE *psize)
Definition: atltest.h:155
int g_atltest_failed
Definition: atltest.h:20
int main(void)
Definition: atltest.h:79
int g_atltest_line
Definition: atltest.h:24
const char * g_atltest_name
void atltest_skip(const char *fmt,...)
Definition: atltest.h:46
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
const char * g_atltest_file
Definition: atltest.h:23
int g_atltest_skipped
Definition: atltest.h:21
void atltest_ok(int value, const char *fmt,...)
Definition: atltest.h:32
#define NULL
Definition: types.h:112
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
#define printf
Definition: freeldr.h:97
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_Check_return_opt_ _CRTIMP int __cdecl vprintf(_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
#define wine_dbgstr_w
Definition: kernel32.h:34
_Out_ LPRECT prc
Definition: ntgdi.h:1658
_Must_inspect_result_ _Out_ LPSIZE psize
Definition: ntgdi.h:1569
#define _countof(array)
Definition: sndvol32.h:70
Definition: fci.c:127
Definition: dsound.c:943
Definition: parser.c:49
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
Definition: pdh_main.c:94
#define IS_INTRESOURCE(i)
Definition: winuser.h:580