Github User Fetcher
1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
internal/theories.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_THEORIES_H_
25
#define CRITERION_INTERNAL_THEORIES_H_
26
27
#include "
test.h
"
28
29
#ifdef __cplusplus
30
# include <cstddef>
31
using
std::size_t
;
32
#else
33
# include <stddef.h>
34
#endif
35
36
#ifdef __cplusplus
37
template
<
typename
... T>
38
constexpr
size_t
criterion_va_num__(
const
T & ...)
39
{
40
return
sizeof
... (T);
41
}
42
#endif
43
44
struct
criterion_datapoints
{
45
size_t
size
;
46
size_t
len
;
47
const
char
*
name
;
48
void
*
arr
;
49
};
50
51
CR_BEGIN_C_API
52
53
CR_API
void
cr_theory_main
(
struct
criterion_datapoints
*dps,
size_t
datapoints,
void
(*fnptr)(
void
));
54
55
CR_END_C_API
56
57
#ifdef __cplusplus
58
# define CR_TH_VA_NUM(Type, ...) criterion_va_num__(__VA_ARGS__)
59
# define CR_TH_TEMP_ARRAY(Type, ...) []() -> Type * { static Type arr[] = { __VA_ARGS__ }; return reinterpret_cast<Type *>(&arr); } ()
60
#else
61
# define CR_TH_VA_NUM(Type, ...) sizeof ((Type[]) { __VA_ARGS__ }) / sizeof (Type)
62
# define CR_TH_TEMP_ARRAY(Type, ...) & (Type[]) { __VA_ARGS__ }
63
#endif
64
65
#define CR_TH_INTERNAL_TDPS(Category, Name) \
66
static struct criterion_datapoints CR_IDENTIFIER_(Category, Name, dps)[]
67
68
#define CR_TH_INTERNAL_TDP(Category, Name) \
69
(CR_IDENTIFIER_(Category, Name, dps))
70
71
#define CR_TH_INTERNAL_DP(Type, ...) \
72
{ \
73
sizeof (Type), \
74
CR_EXPAND(CR_TH_VA_NUM(Type, __VA_ARGS__)), \
75
#Type, \
76
CR_EXPAND(CR_TH_TEMP_ARRAY(Type, __VA_ARGS__)), \
77
}
78
79
#define CR_NB_DATAPOINTS(Var) \
80
(sizeof (Var) / sizeof (struct criterion_datapoints))
81
82
#define CR_VAARG_ID(Suffix, Category, Name, ...) \
83
CR_IDENTIFIER_(Category, Name, Suffix)
84
85
#define CR_THEORY_BASE(Args, ...) \
86
void CR_EXPAND(CR_VAARG_ID(theory, __VA_ARGS__, )) Args; \
87
CR_EXPAND(CR_TEST_BASE(__VA_ARGS__, .sentinel_ = 0)) { \
88
cr_theory_main( \
89
CR_EXPAND(CR_VAARG_ID(dps, __VA_ARGS__, )), \
90
CR_NB_DATAPOINTS(CR_EXPAND(CR_VAARG_ID(dps, __VA_ARGS__, ))), \
91
(void (*)(void))CR_EXPAND(CR_VAARG_ID(theory, __VA_ARGS__, )) \
92
); \
93
} \
94
void CR_EXPAND(CR_VAARG_ID(theory, __VA_ARGS__, )) Args
95
96
#define cr_assume_op_(Op, Actual, Expected) cr_assume((Actual) Op (Expected))
97
98
#define cr_assume_str_op_(Op, Actual, Expected) \
99
cr_assume(strcmp((Actual), (Expected)) Op 0)
100
101
#undef Theory
102
#define Theory(Args, ...) CR_EXPAND(CR_THEORY_BASE(Args, __VA_ARGS__))
103
104
#endif
/* !CRITERION_INTERNAL_THEORIES_H_ */
CR_BEGIN_C_API
#define CR_BEGIN_C_API
Definition
common.h:54
CR_API
#define CR_API
Definition
common.h:128
CR_END_C_API
#define CR_END_C_API
Definition
common.h:55
cr_theory_main
CR_BEGIN_C_API CR_API void cr_theory_main(struct criterion_datapoints *dps, size_t datapoints, void(*fnptr)(void))
std::size_t
decltype(sizeof(void *)) size_t
Definition
doctest.h:524
criterion_datapoints
Definition
internal/theories.h:44
criterion_datapoints::name
const char * name
Definition
internal/theories.h:47
criterion_datapoints::len
size_t len
Definition
internal/theories.h:46
criterion_datapoints::size
size_t size
Definition
internal/theories.h:45
criterion_datapoints::arr
void * arr
Definition
internal/theories.h:48
test.h
nix
store
2xpcmdrzviw89gzpf8p7l7691wk51i89-criterion-2.4.2-dev
include
criterion
internal
theories.h
Generated by
1.10.0