Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
internal/hooks.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_HOOKS_H_
25#define CRITERION_INTERNAL_HOOKS_H_
26
27#include "common.h"
28#include "../types.h"
29
30#define CR_HOOK_IDENTIFIER_(Suffix) CR_HOOK_IDENTIFIER__(__LINE__, Suffix)
31#define CR_HOOK_IDENTIFIER__(Line, Suffix) CR_HOOK_IDENTIFIER___(Line, Suffix)
32#define CR_HOOK_IDENTIFIER___(Line, Suffix) hook_l ## Line ## _ ## Suffix
33
34#ifdef __cplusplus
35# define CR_HOOK_PROTOTYPE_ \
36 extern "C" void CR_HOOK_IDENTIFIER_(impl)
37#else
38# define CR_HOOK_PROTOTYPE_ \
39 void CR_HOOK_IDENTIFIER_(impl)
40#endif
41
42/* Section abbreviations */
43#define CR_HOOK_SECTION_PRE_ALL cr_pra
44#define CR_HOOK_SECTION_PRE_SUITE cr_prs
45#define CR_HOOK_SECTION_PRE_INIT cr_pri
46#define CR_HOOK_SECTION_PRE_TEST cr_prt
47#define CR_HOOK_SECTION_ASSERT cr_ast
48#define CR_HOOK_SECTION_THEORY_FAIL cr_thf
49#define CR_HOOK_SECTION_TEST_CRASH cr_tsc
50#define CR_HOOK_SECTION_POST_TEST cr_pot
51#define CR_HOOK_SECTION_POST_FINI cr_pof
52#define CR_HOOK_SECTION_POST_SUITE cr_pos
53#define CR_HOOK_SECTION_POST_ALL cr_poa
54
55#define CR_HOOK_SECTION(Kind) CR_HOOK_SECTION_ ## Kind
56
57#define CR_HOOK_SECTION_STRINGIFY__(Sec) #Sec
58#define CR_HOOK_SECTION_STRINGIFY_(Sec) CR_HOOK_SECTION_STRINGIFY__(Sec)
59#define CR_HOOK_SECTION_STRINGIFY(Kind) CR_HOOK_SECTION_STRINGIFY_(CR_HOOK_SECTION(Kind))
60
61#define CR_HOOK_PARAM_TYPE_PRE_ALL struct criterion_test_set *
62#define CR_HOOK_PARAM_TYPE_PRE_SUITE struct criterion_suite_set *
63#define CR_HOOK_PARAM_TYPE_PRE_INIT struct criterion_test *
64#define CR_HOOK_PARAM_TYPE_PRE_TEST struct criterion_test *
65#define CR_HOOK_PARAM_TYPE_ASSERT struct criterion_assert_stats *
66#define CR_HOOK_PARAM_TYPE_THEORY_FAIL struct criterion_theory_stats *
67#define CR_HOOK_PARAM_TYPE_TEST_CRASH struct criterion_test_stats *
68#define CR_HOOK_PARAM_TYPE_POST_TEST struct criterion_test_stats *
69#define CR_HOOK_PARAM_TYPE_POST_FINI struct criterion_test_stats *
70#define CR_HOOK_PARAM_TYPE_POST_SUITE struct criterion_suite_stats *
71#define CR_HOOK_PARAM_TYPE_POST_ALL struct criterion_global_stats *
72
73#define CR_HOOK_PARAM_TYPE(Kind) CR_HOOK_PARAM_TYPE_ ## Kind
74
75#define CR_REPORT_HOOK_IMPL(Kind) \
76 CR_HOOK_PROTOTYPE_(CR_HOOK_PARAM_TYPE(Kind)); \
77 CR_SECTION_(CR_HOOK_SECTION_STRINGIFY(Kind)) \
78 f_report_hook CR_HOOK_IDENTIFIER_(func) = \
79 (f_report_hook) CR_HOOK_IDENTIFIER_(impl) \
80 CR_SECTION_SUFFIX_; \
81 CR_HOOK_PROTOTYPE_
82
83#endif /* !CRITERION_INTERNAL_HOOKS_H_ */
Types for tests.