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

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

separate out the sandbox code so that test sandboxes can be created without a tr_session

  • Property svn:keywords set to Date Rev Author Id
File size: 2.4 KB
Line 
1/*
2 * This file Copyright (C) 2010-2014 Mnemosyne LLC
3 *
4 * It may be used under the GNU GPL versions 2 or 3
5 * or any future license endorsed by Mnemosyne LLC.
6 *
7 * $Id: libtransmission-test.h 14288 2014-06-08 19:09:41Z jordan $
8 */
9
10/* Note VERBOSE needs to be (un)defined before including this file */
11
12#ifndef LIBTRANSMISSION_TEST_H
13#define LIBTRANSMISSION_TEST_H 1
14
15#include <stdio.h>
16
17#include "transmission.h"
18#include "utils.h" /* tr_strcmp0 () */
19
20extern int current_test;
21
22extern bool verbose;
23
24bool should_print (bool pass);
25
26bool check_condition_impl (const char * file, int line, bool condition);
27bool check_int_eq_impl (const char * file, int line, int64_t expected, int64_t actual);
28bool check_ptr_eq_impl (const char * file, int line, const void * expected, const void * actual);
29bool check_streq_impl (const char * file, int line, const char * expected, const char * actual);
30
31/***
32****
33***/
34
35#define check(condition) \
36  do { \
37    ++current_test; \
38    if (!check_condition_impl (__FILE__, __LINE__, (condition))) \
39      return current_test; \
40  } while (0)
41
42#define check_streq(expected, actual) \
43  do { \
44    ++current_test; \
45    if (!check_streq_impl (__FILE__, __LINE__, (expected), (actual))) \
46      return current_test; \
47  } while (0)
48
49#define check_int_eq(expected, actual) \
50  do { \
51    ++current_test; \
52    if (!check_int_eq_impl (__FILE__, __LINE__, (expected), (actual))) \
53      return current_test; \
54  } while (0)
55
56#define check_ptr_eq(expected, actual) \
57  do { \
58    ++current_test; \
59    if (!check_ptr_eq_impl (__FILE__, __LINE__, (expected), (actual))) \
60      return current_test; \
61  } while (0)
62
63/***
64****
65***/
66
67typedef int (*testFunc)(void);
68#define NUM_TESTS(tarray)((int)(sizeof (tarray)/sizeof (tarray[0])))
69
70int runTests (const testFunc * const tests, int numTests);
71
72#define MAIN_SINGLE_TEST(test) \
73int main (void) { \
74    const testFunc tests[] = { test }; \
75    return runTests (tests, 1); \
76}
77
78tr_session * libttest_session_init (struct tr_variant * settings);
79void         libttest_session_close (tr_session * session);
80
81void         libttest_zero_torrent_populate (tr_torrent * tor, bool complete);
82tr_torrent * libttest_zero_torrent_init (tr_session * session);
83
84void         libttest_blockingTorrentVerify (tr_torrent * tor);
85
86void         libtest_create_file_with_contents (const char * path, const char * str);
87
88char*        libtest_sandbox_create (void);
89void         libtest_sandbox_destroy (const char * sandbox);
90
91
92
93
94
95#endif /* !LIBTRANSMISSION_TEST_H */
Note: See TracBrowser for help on using the repository browser.