Forgetting to save really sucks. Sorry again for the wasted commit.
[reactos.git] / rostests / apitests / apitest.h
1 #ifndef _APITEST_H
2 #define _APITEST_H
3
4 #include <stdlib.h>
5 #include <stdarg.h>
6 #include <stdio.h>
7 #include <windows.h>
8
9 #define APISTATUS_NORMAL 0
10 #define APISTATUS_NOT_FOUND 1
11 #define APISTATUS_UNIMPLEMENTED 2
12 #define APISTATUS_ASSERTION_FAILED 3
13 #define APISTATUS_REGRESSION 4
14
15 /* type definitions */
16
17 typedef struct tagTESTINFO
18 {
19 INT passed;
20 INT failed;
21 INT rfailed;
22 BOOL bRegress;
23 INT nApiStatus;
24 } TESTINFO, *PTESTINFO;
25
26 typedef INT (*TESTPROC)(PTESTINFO);
27
28 typedef struct tagTEST
29 {
30 WCHAR* Test;
31 TESTPROC Proc;
32 } TESTENTRY, *PTESTENTRY;
33
34
35 /* macros */
36
37 #define TEST(x) \
38 if (pti->bRegress) \
39 { \
40 if (x)\
41 {\
42 (pti->passed)++;\
43 printf("%s:%d: non-rtest succeeded (%s)\n", __FILE__, __LINE__, #x);\
44 } else {\
45 (pti->failed)++;\
46 } \
47 } \
48 else \
49 { \
50 if (x)\
51 {\
52 (pti->passed)++;\
53 } else {\
54 (pti->failed)++;\
55 printf("%s:%d: test failed (%s)\n", __FILE__, __LINE__, #x);\
56 } \
57 }
58
59 #define TESTX(x, format, ...) \
60 if (pti->bRegress) \
61 { \
62 if (x)\
63 {\
64 (pti->passed)++;\
65 printf("%s:%d: non-rtest succeeded (%s)\n", __FILE__, __LINE__, #x);\
66 } else {\
67 (pti->failed)++;\
68 } \
69 } \
70 else \
71 { \
72 if (x)\
73 {\
74 (pti->passed)++;\
75 } else {\
76 (pti->failed)++;\
77 printf("%s:%d: test failed (%s) ", __FILE__, __LINE__, #x);\
78 printf(format, __VA_ARGS__); \
79 } \
80 }
81
82 #define RTEST(x) \
83 if (pti->bRegress) \
84 { \
85 if (x)\
86 {\
87 (pti->passed)++;\
88 } else {\
89 (pti->failed)++;\
90 (pti->rfailed)++;\
91 printf("rtest failed in %s:%d (%s)\n", __FILE__, __LINE__, #x);\
92 } \
93 } \
94 else \
95 { \
96 if (x)\
97 {\
98 (pti->passed)++;\
99 } else {\
100 (pti->failed)++;\
101 printf("test failed in %s:%d (%s)\n", __FILE__, __LINE__, #x);\
102 } \
103 }
104
105 #undef ASSERT
106 #define ASSERT(x) \
107 if (!(x)) \
108 { \
109 printf("Assertion failed in %s:%d (%s)\n", __FILE__, __LINE__, #x);\
110 return APISTATUS_ASSERTION_FAILED; \
111 }
112
113 int TestMain(LPWSTR pszExe, LPWSTR pszModule);
114 extern TESTENTRY TestList[];
115 INT NumTests(void);
116 BOOL IsFunctionPresent(LPWSTR lpszFunction);
117 VOID DumpMem(PVOID pData, ULONG cbSize, ULONG nWidth);
118
119 #endif /* _APITEST_H */