minor debug tags refactoring; implemented call nxlog_get_all_debug_tags; server conso...
[public/netxms.git] / tests / include / testtools.h
CommitLineData
ee2d686f
VK
1#ifndef _testtools_h_
2#define _testtools_h_
3
4/**
5 * Assert failure
6 */
66c11d49
VK
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)
ee2d686f
VK
13
14/**
15 * Assert that two values are equal
16 */
17#define AssertEquals(x, y) Assert((x) == (y))
18
b7306e95
VK
19/**
20 * Assert that two values are not equal
21 */
22#define AssertNotEquals(x, y) Assert((x) != (y))
23
ee2d686f
VK
24/**
25 * Assert that value is TRUE
26 */
27#define AssertTrue(x) Assert((x))
28
66c11d49
VK
29/**
30 * Assert that value is TRUE with message
31 */
32#define AssertTrueEx(x, m) AssertEx((x), (m))
33
ee2d686f
VK
34/**
35 * Assert that value is FALSE
36 */
37#define AssertFalse(x) Assert(!(x))
38
66c11d49
VK
39/**
40 * Assert that value is FALSE with message
41 */
42#define AssertFalseEx(x, m) AssertEx(!(x), (m))
43
ee2d686f
VK
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
66c11d49
VK
54/**
55 * Assert that value is not NULL with message
56 */
57#define AssertNotNullEx(x, m) AssertEx((x) != NULL, (m))
58
ee2d686f
VK
59/**
60 * Show test start mark
61 */
62inline 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);
4b6e5e27 77 fflush(stdout);
ee2d686f
VK
78}
79
80/**
81 * Show test end
82 */
83inline void EndTest()
84{
85 _tprintf(_T("OK\n"));
86}
87
88/**
89 * Show test end with timimg
90 */
91inline void EndTest(INT64 ms)
92{
93 _tprintf(_T("%d ms\n"), (int)ms);
94}
95
96#endif