Github User Fetcher
1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
internal/parameterized.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_PARAMETERIZED_H_
25
#define CRITERION_INTERNAL_PARAMETERIZED_H_
26
27
#include "
test.h
"
28
#include "
../types.h
"
29
30
struct
criterion_test_params
{
31
size_t
size
;
32
void
*
params
;
33
size_t
length
;
34
void (*
cleanup
)(
struct
criterion_test_params
*);
35
36
#ifdef __cplusplus
37
constexpr
criterion_test_params
(
size_t
size
,
void
*
params
,
size_t
length
)
38
:
size
(
size
),
39
params
(
params
),
40
length
(
length
),
41
cleanup
(nullptr)
42
{}
43
44
constexpr
criterion_test_params
(
size_t
size
,
void
*
params
,
size_t
length
,
45
void
(*
cleanup
)(
struct
criterion_test_params
*))
46
:
size
(
size
),
47
params
(
params
),
48
length
(
length
),
49
cleanup
(
cleanup
)
50
{}
51
52
template
<
typename
T>
53
constexpr
criterion_test_params
(std::vector<T, criterion::allocator<T> > &
vec
,
54
void
(*
cleanup
)(
criterion_test_params
*) =
nullptr
)
55
:
size
(sizeof (T)),
56
params
(&
vec
[0]),
57
length
(
vec
.
size
()),
58
cleanup
(
cleanup
)
59
{}
60
61
template
<
typename
T,
unsigned
int
N>
62
constexpr
criterion_test_params
(T (&arr)[N],
63
void
(*
cleanup
)(
criterion_test_params
*) =
nullptr
)
64
:
size
(sizeof (arr[0])),
65
params
(static_cast<void *>(&arr)),
66
length
(N),
67
cleanup
(
cleanup
)
68
{}
69
#endif
70
};
71
72
#ifdef __cplusplus
73
# define CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name) \
74
extern "C" void CR_IDENTIFIER_(Category, Name, impl)(Param)
75
#else
76
# define CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name) \
77
void CR_IDENTIFIER_(Category, Name, impl)(Param)
78
#endif
79
80
#define CR_PARAM_TEST_BASE(Param, Category, Name, ...) \
81
CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name); \
82
CR_TEST_TRAMPOLINE_(Category, Name) \
83
struct criterion_test_extra_data CR_IDENTIFIER_(Category, Name, extra) = \
84
CR_EXPAND(CRITERION_MAKE_STRUCT(criterion_test_extra_data, \
85
.compiler_ = CR_COMPILER_, \
86
.lang_ = CR_LANG, \
87
.kind_ = CR_TEST_PARAMETERIZED, \
88
.param_ = CR_IDENTIFIER_(Category, Name, param), \
89
.identifier_ = #Category "/" #Name, \
90
.file_ = __FILE__, \
91
.line_ = __LINE__, \
92
__VA_ARGS__ \
93
)); \
94
struct criterion_test CR_IDENTIFIER_(Category, Name, meta) = { \
95
#Name, \
96
#Category, \
97
CR_IDENTIFIER_(Category, Name, jmp), \
98
&CR_IDENTIFIER_(Category, Name, extra) \
99
}; \
100
CR_SECTION_("cr_tst") \
101
struct criterion_test *CR_IDENTIFIER_(Category, Name, ptr) \
102
= &CR_IDENTIFIER_(Category, Name, meta) CR_SECTION_SUFFIX_; \
103
CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name)
104
105
#define CR_PARAM_TEST_PARAMS(Category, Name) \
106
static struct criterion_test_params CR_IDENTIFIER_(Category, Name, param)(void)
107
108
#ifdef __cplusplus
109
# define cr_make_param_array_(Type, Array, ...) \
110
criterion_test_params(sizeof (Type), (Array), __VA_ARGS__)
111
#else
112
# define cr_make_param_array_(Type, Array, ...) \
113
(struct criterion_test_params) { .size = sizeof (Type), (void *) (Array), __VA_ARGS__ }
114
#endif
115
116
#undef ParameterizedTest
117
#define ParameterizedTest(...) CR_EXPAND(CR_PARAM_TEST_BASE(__VA_ARGS__, .sentinel_ = 0))
118
119
#undef ParameterizedTestParameters
120
#define ParameterizedTestParameters(Suite, Name) CR_PARAM_TEST_PARAMS(Suite, Name)
121
122
#undef cr_make_param_array
123
#define cr_make_param_array(...) CR_EXPAND(cr_make_param_array_(__VA_ARGS__))
124
125
#endif
/* !CRITERION_INTERNAL_PARAMETERIZED_H_ */
criterion_test_params
Definition
internal/parameterized.h:30
criterion_test_params::cleanup
void(* cleanup)(struct criterion_test_params *)
Definition
internal/parameterized.h:34
criterion_test_params::length
size_t length
Definition
internal/parameterized.h:33
criterion_test_params::params
void * params
Definition
internal/parameterized.h:32
criterion_test_params::size
size_t size
Definition
internal/parameterized.h:31
vec
Definition
civetweb.c:1864
test.h
types.h
Types for tests.
nix
store
2xpcmdrzviw89gzpf8p7l7691wk51i89-criterion-2.4.2-dev
include
criterion
internal
parameterized.h
Generated by
1.10.0