1 | /* Note VERBOSE needs to be (un)defined before including this file */ |
---|
2 | |
---|
3 | #ifndef LIBTRANSMISSION_TEST_H |
---|
4 | #define LIBTRANSMISSION_TEST_H 1 |
---|
5 | |
---|
6 | #include <stdio.h> |
---|
7 | |
---|
8 | #include "transmission.h" |
---|
9 | #include "utils.h" /* tr_strcmp0 () */ |
---|
10 | |
---|
11 | extern int current_test; |
---|
12 | |
---|
13 | extern bool verbose; |
---|
14 | |
---|
15 | bool should_print (bool pass); |
---|
16 | |
---|
17 | bool check_condition_impl (const char * file, int line, bool condition); |
---|
18 | bool check_int_eq_impl (const char * file, int line, int64_t expected, int64_t actual); |
---|
19 | bool check_ptr_eq_impl (const char * file, int line, const void * expected, const void * actual); |
---|
20 | bool check_streq_impl (const char * file, int line, const char * expected, const char * actual); |
---|
21 | |
---|
22 | /*** |
---|
23 | **** |
---|
24 | ***/ |
---|
25 | |
---|
26 | #define check(condition) \ |
---|
27 | do { \ |
---|
28 | ++current_test; \ |
---|
29 | if (!check_condition_impl (__FILE__, __LINE__, (condition))) \ |
---|
30 | return current_test; \ |
---|
31 | } while (0) |
---|
32 | |
---|
33 | #define check_streq(expected, actual) \ |
---|
34 | do { \ |
---|
35 | ++current_test; \ |
---|
36 | if (!check_streq_impl (__FILE__, __LINE__, (expected), (actual))) \ |
---|
37 | return current_test; \ |
---|
38 | } while (0) |
---|
39 | |
---|
40 | #define check_int_eq(expected, actual) \ |
---|
41 | do { \ |
---|
42 | ++current_test; \ |
---|
43 | if (!check_int_eq_impl (__FILE__, __LINE__, (expected), (actual))) \ |
---|
44 | return current_test; \ |
---|
45 | } while (0) |
---|
46 | |
---|
47 | #define check_ptr_eq(expected, actual) \ |
---|
48 | do { \ |
---|
49 | ++current_test; \ |
---|
50 | if (!check_ptr_eq_impl (__FILE__, __LINE__, (expected), (actual))) \ |
---|
51 | return current_test; \ |
---|
52 | } while (0) |
---|
53 | |
---|
54 | /*** |
---|
55 | **** |
---|
56 | ***/ |
---|
57 | |
---|
58 | typedef int (*testFunc)(void); |
---|
59 | #define NUM_TESTS(tarray)((int)(sizeof (tarray)/sizeof (tarray[0]))) |
---|
60 | |
---|
61 | int runTests (const testFunc * const tests, int numTests); |
---|
62 | |
---|
63 | #define MAIN_SINGLE_TEST(test) \ |
---|
64 | int main (void) { \ |
---|
65 | const testFunc tests[] = { test }; \ |
---|
66 | return runTests (tests, 1); \ |
---|
67 | } |
---|
68 | |
---|
69 | extern tr_session * session; |
---|
70 | extern char * sandbox; |
---|
71 | extern char * downloadDir; |
---|
72 | extern char * blocklistDir; |
---|
73 | |
---|
74 | void libtransmission_test_session_init_formatters (void); |
---|
75 | void libtransmission_test_session_init_sandbox (void); |
---|
76 | void libtransmission_test_session_init_session (void); |
---|
77 | void libtransmission_test_session_init (void); /* utility; calls the other 3 */ |
---|
78 | |
---|
79 | void libtransmission_test_session_close (void); |
---|
80 | |
---|
81 | void libtransmission_test_zero_torrent_populate (tr_torrent * tor, bool complete); |
---|
82 | tr_torrent * libtransmission_test_zero_torrent_init (void); |
---|
83 | |
---|
84 | void libttest_blockingTorrentVerify (tr_torrent * tor); |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | #endif /* !LIBTRANSMISSION_TEST_H */ |
---|