source: trunk/libtransmission/libtransmission-test.h @ 13879

Last change on this file since 13879 was 13879, checked in by jordan, 8 years ago

(libT) add package-visible API hook for when a block is downloaded. Add unit test to confirm that when the last file finishes downloading, its .part suffix is removed and it's moved from the incomplete to complete dir

File size: 2.3 KB
Line 
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
11extern int current_test;
12
13extern bool verbose;
14
15bool should_print (bool pass);
16
17bool check_condition_impl (const char * file, int line, bool condition);
18bool check_int_eq_impl (const char * file, int line, int64_t expected, int64_t actual);
19bool check_ptr_eq_impl (const char * file, int line, const void * expected, const void * actual);
20bool 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
58typedef int (*testFunc)(void);
59#define NUM_TESTS(tarray)((int)(sizeof (tarray)/sizeof (tarray[0])))
60
61int runTests (const testFunc * const tests, int numTests);
62
63#define MAIN_SINGLE_TEST(test) \
64int main (void) { \
65    const testFunc tests[] = { test }; \
66    return runTests (tests, 1); \
67}
68
69extern tr_session * session;
70extern char * sandbox;
71extern char * downloadDir;
72extern char * blocklistDir;
73
74void libtransmission_test_session_init_formatters (void);
75void libtransmission_test_session_init_sandbox (void);
76void libtransmission_test_session_init_session (void);
77void libtransmission_test_session_init (void); /* utility; calls the other 3 */
78
79void libtransmission_test_session_close (void);
80
81void         libtransmission_test_zero_torrent_populate (tr_torrent * tor, bool complete);
82tr_torrent * libtransmission_test_zero_torrent_init (void);
83
84
85
86#endif /* !LIBTRANSMISSION_TEST_H */
Note: See TracBrowser for help on using the repository browser.