minor debug tags refactoring; implemented call nxlog_get_all_debug_tags; server conso...
[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 two values are not equal
21 */
22 #define AssertNotEquals(x, y) Assert((x) != (y))
23
24 /**
25 * Assert that value is TRUE
26 */
27 #define AssertTrue(x) Assert((x))
28
29 /**
30 * Assert that value is TRUE with message
31 */
32 #define AssertTrueEx(x, m) AssertEx((x), (m))
33
34 /**
35 * Assert that value is FALSE
36 */
37 #define AssertFalse(x) Assert(!(x))
38
39 /**
40 * Assert that value is FALSE with message
41 */
42 #define AssertFalseEx(x, m) AssertEx(!(x), (m))
43
44 /**
45 * Assert that value is NULL
46 */
47 #define AssertNull(x) Assert((x) == NULL)
48
49 /**
50 * Assert that value is not NULL
51 */
52 #define AssertNotNull(x) Assert((x) != NULL)
53
54 /**
55 * Assert that value is not NULL with message
56 */
57 #define AssertNotNullEx(x, m) AssertEx((x) != NULL, (m))
58
59 /**
60 * Show test start mark
61 */
62 inline void StartTest(const TCHAR *name)
63 {
64 TCHAR filler[80];
65 int l = 60 - (int)_tcslen(name);
66 if (l > 0)
67 {
68 for(int i = 0; i < l; i++)
69 filler[i] = _T('.');
70 filler[l] = 0;
71 }
72 else
73 {
74 filler[0] = 0;
75 }
76 _tprintf(_T("%s %s "), name, filler);
77 fflush(stdout);
78 }
79
80 /**
81 * Show test end
82 */
83 inline void EndTest()
84 {
85 _tprintf(_T("OK\n"));
86 }
87
88 /**
89 * Show test end with timimg
90 */
91 inline void EndTest(INT64 ms)
92 {
93 _tprintf(_T("%d ms\n"), (int)ms);
94 }
95
96 #endif