Github User Fetcher
1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
exceptions.h
Go to the documentation of this file.
1
/*
2
* The MIT License (MIT)
3
*
4
* Copyright © 2017 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_ASSERT_EXCEPTIONS_H_
25
#define CRITERION_INTERNAL_ASSERT_EXCEPTIONS_H_
26
27
/* Exception specifiers */
28
29
#define CRI_ASSERT_TEST_SPECIFIER_throw(...) ,
30
#define CRI_ASSERT_SPECIFIER_throw(Ex, Stmt) \
31
cri_cond_def; do { \
32
cri_assert_node_init(&cri_tmpn); \
33
cri_tmpn.repr = "throw(" #Ex ", " #Stmt ")"; \
34
try { \
35
Stmt; \
36
cri_cond_un = 0; \
37
char *cri_str; \
38
cr_asprintf(&cri_str, "<nothing was thrown>"); \
39
cri_tmpn.params[0].name = "message"; \
40
cri_tmpn.params[0].type = CRI_ASSERT_RT_STR; \
41
cri_tmpn.params[0].data = cri_str; \
42
} catch (Ex &cri_ex) { \
43
cri_cond_un = 1; \
44
} catch (std::exception &cri_ex) { \
45
cri_cond_un = 0; \
46
const char *cri_what = cri_ex.what(); \
47
char *cri_str = cr_user_str_tostr(&cri_what); \
48
cri_tmpn.params[0].name = "message"; \
49
cri_tmpn.params[0].type = CRI_ASSERT_RT_STR; \
50
cri_tmpn.params[0].data = cri_str; \
51
} catch (...) { \
52
cri_cond_un = 0; \
53
char *cri_str; \
54
cr_asprintf(&cri_str, "<unprintable>"); \
55
cri_tmpn.params[0].name = "message"; \
56
cri_tmpn.params[0].type = CRI_ASSERT_RT_STR; \
57
cri_tmpn.params[0].data = cri_str; \
58
} \
59
cri_prevnode = cri_assert_node_add(cri_node, &cri_tmpn); \
60
} while (0)
61
62
#define CRI_ASSERT_TEST_SPECIFIER_nothrow(...) ,
63
#define CRI_ASSERT_SPECIFIER_nothrow(Stmt) \
64
cri_cond_def; do { \
65
cri_assert_node_init(&cri_tmpn); \
66
cri_tmpn.repr = "nothrow(" #Stmt ")"; \
67
try { \
68
Stmt; \
69
cri_cond_un = 1; \
70
} catch (std::exception &cri_ex) { \
71
cri_cond_un = 0; \
72
const char *cri_what = cri_ex.what(); \
73
char *cri_str = cr_user_str_tostr(&cri_what); \
74
cri_tmpn.params[0].name = "message"; \
75
cri_tmpn.params[0].type = CRI_ASSERT_RT_STR; \
76
cri_tmpn.params[0].data = cri_str; \
77
} catch (...) { \
78
cri_cond_un = 0; \
79
char *cri_str; \
80
cr_asprintf(&cri_str, "<unprintable>"); \
81
cri_tmpn.params[0].name = "message"; \
82
cri_tmpn.params[0].type = CRI_ASSERT_RT_STR; \
83
cri_tmpn.params[0].data = cri_str; \
84
} \
85
cri_prevnode = cri_assert_node_add(cri_node, &cri_tmpn); \
86
} while (0)
87
88
#define CRI_ASSERT_TEST_SPECIFIER_anythrow(...) ,
89
#define CRI_ASSERT_SPECIFIER_anythrow(Stmt) \
90
cri_cond_def; do { \
91
cri_assert_node_init(&cri_tmpn); \
92
cri_tmpn.repr = "anythrow(" #Stmt ")"; \
93
try { \
94
Stmt; \
95
cri_cond_un = 0; \
96
} catch (...) { \
97
cri_cond_un = 1; \
98
char *cri_str; \
99
cr_asprintf(&cri_str, "<unprintable>"); \
100
cri_tmpn.params[0].name = "message"; \
101
cri_tmpn.params[0].type = CRI_ASSERT_RT_STR; \
102
cri_tmpn.params[0].data = cri_str; \
103
} \
104
cri_prevnode = cri_assert_node_add(cri_node, &cri_tmpn); \
105
} while (0)
106
107
#endif
/* !CRITERION_INTERNAL_ASSERT_EXCEPTIONS_H_ */
nix
store
2xpcmdrzviw89gzpf8p7l7691wk51i89-criterion-2.4.2-dev
include
criterion
internal
assert
exceptions.h
Generated by
1.10.0