source: trunk/libtransmission/libtransmission-test.h

Last change on this file was 14724, checked in by jordan, 5 years ago

use '#pragma once' instead of #ifndef..#define..#endif guards

  • Property svn:keywords set to Date Rev Author Id
File size: 2.9 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 14724 2016-03-29 16:37:21Z mikedld $
8 */
9
10/* Note VERBOSE needs to be (un)defined before including this file */
11
12#pragma once
13
14#include <stdio.h>
15#include <string.h> /* strlen() */
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_uint_eq_impl   (const char * file, int line, uint64_t     expected, uint64_t     actual);
29bool check_ptr_eq_impl    (const char * file, int line, const void * expected, const void * actual);
30bool check_streq_impl     (const char * file, int line, const char * expected, const char * actual);
31
32/***
33****
34***/
35
36#define check(condition) \
37  do { \
38    ++current_test; \
39    if (!check_condition_impl (__FILE__, __LINE__, (condition))) \
40      return current_test; \
41  } while (0)
42
43#define check_streq(expected, actual) \
44  do { \
45    ++current_test; \
46    if (!check_streq_impl (__FILE__, __LINE__, (expected), (actual))) \
47      return current_test; \
48  } while (0)
49
50#define check_int_eq(expected, actual) \
51  do { \
52    ++current_test; \
53    if (!check_int_eq_impl (__FILE__, __LINE__, (expected), (actual))) \
54      return current_test; \
55  } while (0)
56
57#define check_uint_eq(expected, actual) \
58  do { \
59    ++current_test; \
60    if (!check_uint_eq_impl (__FILE__, __LINE__, (expected), (actual))) \
61      return current_test; \
62  } while (0)
63
64#define check_ptr_eq(expected, actual) \
65  do { \
66    ++current_test; \
67    if (!check_ptr_eq_impl (__FILE__, __LINE__, (expected), (actual))) \
68      return current_test; \
69  } while (0)
70
71/***
72****
73***/
74
75typedef int (*testFunc)(void);
76#define NUM_TESTS(tarray)((int)(sizeof (tarray)/sizeof (tarray[0])))
77
78int runTests (const testFunc * const tests, int numTests);
79
80#define MAIN_SINGLE_TEST(test) \
81int main (void) { \
82    const testFunc tests[] = { test }; \
83    return runTests (tests, 1); \
84}
85
86tr_session * libttest_session_init (struct tr_variant * settings);
87void         libttest_session_close (tr_session * session);
88
89void         libttest_zero_torrent_populate (tr_torrent * tor, bool complete);
90tr_torrent * libttest_zero_torrent_init (tr_session * session);
91
92void         libttest_blockingTorrentVerify (tr_torrent * tor);
93
94void         libtest_create_file_with_contents (const char * path, const void* contents, size_t n);
95void         libtest_create_tmpfile_with_contents (char* tmpl, const void* payload, size_t n);
96void         libtest_create_file_with_string_contents (const char * path, const char* str);
97
98char*        libtest_sandbox_create (void);
99void         libtest_sandbox_destroy (const char * sandbox);
100
101void         libttest_sync (void);
102
Note: See TracBrowser for help on using the repository browser.