Fixed Windows build; added missing VC++ project file
[public/netxms.git] / tests / include / testtools.h
1 #ifndef _testtools_h_
2 #define _testtools_h_
3
4 /**
5 * Assert failure
6 */
7 #define Assert(c) do { if (!(c)) { _tprintf(_T("FAIL\n Assert failed at %hs:%d\n"), __FILE__, __LINE__); exit(1); } } while(0)
8
9 /**
10 * Assert failure with additional message
11 */
12 #define AssertEx(c, m) do { if (!(c)) { _tprintf(_T("FAIL\n %s\n Assert failed at %hs:%d\n"), (m), __FILE__, __LINE__); exit(1); } } while(0)
13
14 /**
15 * Assert that two values are equal
16 */
17 #define AssertEquals(x, y) Assert((x) == (y))
18
19 /**
20 * Assert that value is TRUE
21 */
22 #define AssertTrue(x) Assert((x))
23
24 /**
25 * Assert that value is TRUE with message
26 */
27 #define AssertTrueEx(x, m) AssertEx((x), (m))
28
29 /**
30 * Assert that value is FALSE
31 */
32 #define AssertFalse(x) Assert(!(x))
33
34 /**
35 * Assert that value is FALSE with message
36 */
37 #define AssertFalseEx(x, m) AssertEx(!(x), (m))
38
39 /**
40 * Assert that value is NULL
41 */
42 #define AssertNull(x) Assert((x) == NULL)
43
44 /**
45 * Assert that value is not NULL
46 */
47 #define AssertNotNull(x) Assert((x) != NULL)
48
49 /**
50 * Assert that value is not NULL with message
51 */
52 #define AssertNotNullEx(x, m) AssertEx((x) != NULL, (m))
53
54 /**
55 * Show test start mark
56 */
57 inline void StartTest(const TCHAR *name)
58 {
59 TCHAR filler[80];
60 int l = 60 - (int)_tcslen(name);
61 if (l > 0)
62 {
63 for(int i = 0; i < l; i++)
64 filler[i] = _T('.');
65 filler[l] = 0;
66 }
67 else
68 {
69 filler[0] = 0;
70 }
71 _tprintf(_T("%s %s "), name, filler);
72 fflush(stdout);
73 }
74
75 /**
76 * Show test end
77 */
78 inline void EndTest()
79 {
80 _tprintf(_T("OK\n"));
81 }
82
83 /**
84 * Show test end with timimg
85 */
86 inline void EndTest(INT64 ms)
87 {
88 _tprintf(_T("%d ms\n"), (int)ms);
89 }
90
91 #endif