chiark / gitweb /
Simple test for compare_path_raw(). It's moved into a separate source
[disorder] / lib / test.h
CommitLineData
b90f122b
RK
1/*
2 * This file is part of DisOrder.
3 * Copyright (C) 2005, 2007, 2008 Richard Kettlewell
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 * USA
19 */
20/** @file lib/test.h @brief Library tests */
21
22#ifndef TEST_H
23#define TEST_H
24
25#include <config.h>
26#include "types.h"
27
28#include <stdio.h>
29#include <string.h>
30#include <stdlib.h>
31#include <errno.h>
32#include <ctype.h>
33#include <assert.h>
34#include <sys/types.h>
35#include <sys/stat.h>
36#include <unistd.h>
37#include <signal.h>
38#include <sys/wait.h>
39#include <stddef.h>
40#include <sys/socket.h>
41#include <netdb.h>
42#include <netinet/in.h>
43#include <sys/un.h>
44#include <pcre.h>
45
46#include "mem.h"
47#include "log.h"
48#include "vector.h"
49#include "charset.h"
50#include "mime.h"
51#include "hex.h"
52#include "heap.h"
53#include "unicode.h"
54#include "inputline.h"
55#include "wstat.h"
56#include "signame.h"
57#include "cache.h"
58#include "filepart.h"
59#include "hash.h"
60#include "selection.h"
61#include "syscalls.h"
62#include "kvp.h"
63#include "sink.h"
64#include "printf.h"
65#include "basen.h"
66#include "split.h"
67#include "configuration.h"
68#include "addr.h"
69#include "base64.h"
70#include "url.h"
71#include "regsub.h"
72
f9d42b20 73extern long long tests, errors;
b90f122b
RK
74extern int fail_first;
75
76/** @brief Checks that @p expr is nonzero */
77#define insist(expr) do { \
78 if(!(expr)) { \
79 count_error(); \
80 fprintf(stderr, "%s:%d: error checking %s\n", \
81 __FILE__, __LINE__, #expr); \
82 } \
83 ++tests; \
84} while(0)
85
86#define check_string(GOT, WANT) do { \
87 const char *got = GOT; \
88 const char *want = WANT; \
89 \
90 if(want == 0) { \
91 fprintf(stderr, "%s:%d: %s returned 0\n", \
92 __FILE__, __LINE__, #GOT); \
93 count_error(); \
94 } else if(strcmp(want, got)) { \
95 fprintf(stderr, "%s:%d: %s returned:\n%s\nexpected:\n%s\n", \
96 __FILE__, __LINE__, #GOT, format(got), format(want)); \
97 count_error(); \
98 } \
99 ++tests; \
100 } while(0)
101
102#define check_string_prefix(GOT, WANT) do { \
103 const char *got = GOT; \
104 const char *want = WANT; \
105 \
106 if(want == 0) { \
107 fprintf(stderr, "%s:%d: %s returned 0\n", \
108 __FILE__, __LINE__, #GOT); \
109 count_error(); \
110 } else if(strncmp(want, got, strlen(want))) { \
111 fprintf(stderr, "%s:%d: %s returned:\n%s\nexpected:\n%s...\n", \
112 __FILE__, __LINE__, #GOT, format(got), format(want)); \
113 count_error(); \
114 } \
115 ++tests; \
116 } while(0)
117
118#define check_integer(GOT, WANT) do { \
119 const intmax_t got = GOT, want = WANT; \
120 if(got != want) { \
121 fprintf(stderr, "%s:%d: %s returned: %jd expected: %jd\n", \
122 __FILE__, __LINE__, #GOT, got, want); \
123 count_error(); \
124 } \
125 ++tests; \
126} while(0)
127
128void count_error(void);
129const char *format(const char *s);
130const char *format_utf32(const uint32_t *s);
131uint32_t *ucs4parse(const char *s);
132const char *do_printf(const char *fmt, ...);
133
134void test_addr(void);
135void test_basen(void);
136void test_cache(void);
137void test_casefold(void);
138void test_cookies(void);
139void test_filepart(void);
140void test_hash(void);
141void test_heap(void);
142void test_hex(void);
143void test_kvp(void);
144void test_mime(void);
145void test_printf(void);
146void test_regsub(void);
147void test_selection(void);
148void test_signame(void);
149void test_sink(void);
150void test_split(void);
151void test_unicode(void);
152void test_url(void);
153void test_utf8(void);
154void test_words(void);
155void test_wstat(void);
f9d42b20 156void test_bits(void);
d85d9095 157void test_vector(void);
c3c40090 158void test_syscalls(void);
e307c6fe 159void test_trackname(void);
b90f122b
RK
160
161#endif /* TEST_H */
162
163/*
164Local Variables:
165c-basic-offset:2
166comment-column:40
167fill-column:79
168indent-tabs-mode:nil
169End:
170*/