Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
internal/redirect.h
Go to the documentation of this file.
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24#ifndef CRITERION_INTERNAL_REDIRECT_H_
25#define CRITERION_INTERNAL_REDIRECT_H_
26
27#include "common.h"
28#include "assert.h"
29
31
33CR_API int cr_stdout_match_str(const char *ref);
35CR_API int cr_stderr_match_str(const char *ref);
36
38
39#define cr_assert_redir_op_(Fail, Fun, Op, File, Str, ...) \
40 CR_EXPAND(cr_assert_impl( \
41 Fail, \
42 !(Fun((File), (Str)) Op 0), \
43 dummy, \
44 CRITERION_ASSERT_MSG_FILE_STR_MATCH, \
45 (CR_STR(File), Str), \
46 __VA_ARGS__ \
47 ))
48
49#define cr_assert_redir_op_va_(Fail, Fun, Op, ...) \
50 CR_EXPAND(cr_assert_redir_op_( \
51 Fail, \
52 Fun, \
53 Op, \
54 CR_VA_HEAD(__VA_ARGS__), \
55 CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
56 CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
57 ))
58
59#define cr_assert_redir_f_op_(Fail, Fun, Op, File, Ref, ...) \
60 CR_EXPAND(cr_assert_impl( \
61 Fail, \
62 !(Fun((File), (Ref)) Op 0), \
63 dummy, \
64 CRITERION_ASSERT_MSG_FILE_MATCH, \
65 (CR_STR(File), CR_STR(Ref)), \
66 __VA_ARGS__ \
67 ))
68
69#define cr_assert_redir_f_op_va_(Fail, Fun, Op, ...) \
70 CR_EXPAND(cr_assert_redir_f_op_( \
71 Fail, \
72 Fun, \
73 Op, \
74 CR_VA_HEAD(__VA_ARGS__), \
75 CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
76 CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
77 ))
78
79#undef cr_assert_file_contents_eq_str
80#define cr_assert_file_contents_eq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_ABORT_, cr_file_match_str, ==, __VA_ARGS__))
81#undef cr_expect_file_contents_eq_str
82#define cr_expect_file_contents_eq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_CONTINUES_, cr_file_match_str, ==, __VA_ARGS__))
83#undef cr_assert_file_contents_neq_str
84#define cr_assert_file_contents_neq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_ABORT_, cr_file_match_str, !=, __VA_ARGS__))
85#undef cr_expect_file_contents_neq_str
86#define cr_expect_file_contents_neq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_CONTINUES_, cr_file_match_str, !=, __VA_ARGS__))
87#undef cr_assert_file_contents_eq
88#define cr_assert_file_contents_eq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_ABORT_, cr_file_match_file, ==, __VA_ARGS__))
89#undef cr_expect_file_contents_eq
90#define cr_expect_file_contents_eq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_CONTINUES_, cr_file_match_file, ==, __VA_ARGS__))
91#undef cr_assert_file_contents_neq
92#define cr_assert_file_contents_neq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_ABORT_, cr_file_match_file, !=, __VA_ARGS__))
93#undef cr_expect_file_contents_neq
94#define cr_expect_file_contents_neq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_CONTINUES_, cr_file_match_file, !=, __VA_ARGS__))
95
96#undef cr_assert_stdout_eq_str
97#define cr_assert_stdout_eq_str(...) CR_EXPAND(cr_assert_redir_unop_va_(CR_FAIL_ABORT_, cr_stdout_match_str, ==, stdout, __VA_ARGS__))
98#undef cr_expect_stdout_eq_str
99#define cr_expect_stdout_eq_str(...) CR_EXPAND(cr_assert_redir_unop_va_(CR_FAIL_CONTINUES_, cr_stdout_match_str, ==, stdout, __VA_ARGS__))
100#undef cr_assert_stdout_neq_str
101#define cr_assert_stdout_neq_str(...) CR_EXPAND(cr_assert_redir_unop_va_(CR_FAIL_ABORT_, cr_stdout_match_str, !=, stdout, __VA_ARGS__))
102#undef cr_expect_stdout_neq_str
103#define cr_expect_stdout_neq_str(...) CR_EXPAND(cr_assert_redir_unop_va_(CR_FAIL_CONTINUES_, cr_stdout_match_str, !=, stdout, __VA_ARGS__))
104#undef cr_assert_stderr_eq_str
105#define cr_assert_stderr_eq_str(...) CR_EXPAND(cr_assert_redir_unop_va_(CR_FAIL_ABORT_, cr_stderr_match_str, ==, stderr, __VA_ARGS__))
106#undef cr_expect_stderr_eq_str
107#define cr_expect_stderr_eq_str(...) CR_EXPAND(cr_assert_redir_unop_va_(CR_FAIL_CONTINUES_, cr_stderr_match_str, ==, stderr, __VA_ARGS__))
108#undef cr_assert_stderr_neq_str
109#define cr_assert_stderr_neq_str(...) CR_EXPAND(cr_assert_redir_unop_va_(CR_FAIL_ABORT_, cr_stderr_match_str, !=, stderr, __VA_ARGS__))
110#undef cr_expect_stderr_neq_str
111#define cr_expect_stderr_neq_str(...) CR_EXPAND(cr_assert_redir_unop_va_(CR_FAIL_CONTINUES_, cr_stderr_match_str, !=, stderr, __VA_ARGS__))
112#undef cr_assert_stdout_eq
113#define cr_assert_stdout_eq(...) CR_EXPAND(cr_assert_redir_f_unop_va_(CR_FAIL_ABORT_, cr_stdout_match_file, ==, stdout, __VA_ARGS__))
114#undef cr_expect_stdout_eq
115#define cr_expect_stdout_eq(...) CR_EXPAND(cr_assert_redir_f_unop_va_(CR_FAIL_CONTINUES_, cr_stdout_match_file, ==, stdout, __VA_ARGS__))
116#undef cr_assert_stdout_neq
117#define cr_assert_stdout_neq(...) CR_EXPAND(cr_assert_redir_f_unop_va_(CR_FAIL_ABORT_, cr_stdout_match_file, !=, stdout, __VA_ARGS__))
118#undef cr_expect_stdout_neq
119#define cr_expect_stdout_neq(...) CR_EXPAND(cr_assert_redir_f_unop_va_(CR_FAIL_CONTINUES_, cr_stdout_match_file, !=, stdout, __VA_ARGS__))
120#undef cr_assert_stderr_eq
121#define cr_assert_stderr_eq(...) CR_EXPAND(cr_assert_redir_f_unop_va_(CR_FAIL_ABORT_, cr_stderr_match_file, ==, stderr, __VA_ARGS__))
122#undef cr_expect_stderr_eq
123#define cr_expect_stderr_eq(...) CR_EXPAND(cr_assert_redir_f_unop_va_(CR_FAIL_CONTINUES_, cr_stderr_match_file, ==, stderr, __VA_ARGS__))
124#undef cr_assert_stderr_neq
125#define cr_assert_stderr_neq(...) CR_EXPAND(cr_assert_redir_f_unop_va_(CR_FAIL_ABORT_, cr_stderr_match_file, !=, stderr, __VA_ARGS__))
126#undef cr_expect_stderr_neq
127#define cr_expect_stderr_neq(...) CR_EXPAND(cr_assert_redir_f_unop_va_(CR_FAIL_CONTINUES_, cr_stderr_match_file, !=, stderr, __VA_ARGS__))
128
129#define cr_assert_redir_unop_(Fail, Fun, Op, File, Str, ...) \
130 CR_EXPAND(cr_assert_impl( \
131 Fail, \
132 !(Fun((Str)) Op 0), \
133 dummy, \
134 CRITERION_ASSERT_MSG_FILE_STR_MATCH, \
135 (CR_STR(File), Str), \
136 __VA_ARGS__ \
137 ))
138
139#define cr_assert_redir_unop_va_(Fail, Fun, Op, ...) \
140 CR_EXPAND(cr_assert_redir_unop_( \
141 Fail, \
142 Fun, \
143 Op, \
144 CR_VA_HEAD(__VA_ARGS__), \
145 CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
146 CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
147 ))
148
149#define cr_assert_redir_f_unop_(Fail, Fun, Op, File, Ref, ...) \
150 CR_EXPAND(cr_assert_impl( \
151 Fail, \
152 !(Fun((Ref)) Op 0), \
153 dummy, \
154 CRITERION_ASSERT_MSG_FILE_MATCH, \
155 (CR_STR(File), CR_STR(Ref)), \
156 __VA_ARGS__ \
157 ))
158
159#define cr_assert_redir_f_unop_va_(Fail, Fun, Op, ...) \
160 CR_EXPAND(cr_assert_redir_f_unop_( \
161 Fail, \
162 Fun, \
163 Op, \
164 CR_VA_HEAD(__VA_ARGS__), \
165 CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
166 CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
167 ))
168
169#endif /* !CRITERION_INTERNAL_REDIRECT_H_ */
#define CR_BEGIN_C_API
Definition common.h:54
#define CR_API
Definition common.h:128
#define CR_END_C_API
Definition common.h:55
#define CR_STDN
Definition common.h:136
CR_API int cr_stdout_match_str(const char *ref)
CR_API int cr_stderr_match_file(CR_STDN FILE *ref)
CR_API int cr_stderr_match_str(const char *ref)
CR_BEGIN_C_API CR_API int cr_stdout_match_file(CR_STDN FILE *ref)