Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
test.h File Reference
#include "designated-initializer-compat.h"
#include "common.h"
#include "assert.h"

Go to the source code of this file.

Macros

#define CR_IDENTIFIER_(Category, Name, Suffix)    Category ## _ ## Name ## _ ## Suffix
 
#define CR_LANG   CR_LANG_C
 
#define CR_TEST_PROTOTYPE_(Category, Name)    void CR_IDENTIFIER_(Category, Name, impl)(void)
 
#define CR_SUITE_IDENTIFIER_(Name, Suffix)    suite_ ## Name ## _ ## Suffix
 
#define CR_TEST_TRAMPOLINE_(Category, Name)
 
#define CR_COMPILER_   CR_COMP_UNKNOWN
 
#define CR_TEST_BASE(Category, Name, ...)
 
#define CR_SUITE_BASE(Name, ...)
 
#define Test(...)   CR_EXPAND(CR_TEST_BASE(__VA_ARGS__, .sentinel_ = 0))
 
#define TestSuite(...)   CR_EXPAND(CR_SUITE_BASE(__VA_ARGS__, .sentinel_ = 0))
 

Functions

CR_BEGIN_C_API CR_API void criterion_internal_test_setup (void)
 
CR_API void criterion_internal_test_main (void(*fn)(void))
 
CR_API void criterion_internal_test_teardown (void)
 

Variables

static CR_END_C_API const char *const cr_msg_test_init_std_exception = "Caught an unexpected exception during the test initialization: %s."
 
static const char *const cr_msg_test_init_other_exception = "Caught some unexpected exception during the test initialization."
 
static const char *const cr_msg_test_main_std_exception = "Caught an unexpected exception during the test execution: %s."
 
static const char *const cr_msg_test_main_other_exception = "Caught some unexpected exception during the test execution."
 
static const char *const cr_msg_test_fini_std_exception = "Caught an unexpected exception during the test finalization: %s."
 
static const char *const cr_msg_test_fini_other_exception = "Caught some unexpected exception during the test finalization."
 

Macro Definition Documentation

◆ CR_COMPILER_

#define CR_COMPILER_   CR_COMP_UNKNOWN

Definition at line 153 of file test.h.

◆ CR_IDENTIFIER_

#define CR_IDENTIFIER_ ( Category,
Name,
Suffix )    Category ## _ ## Name ## _ ## Suffix

Definition at line 39 of file test.h.

39#define CR_IDENTIFIER_(Category, Name, Suffix) \
40 Category ## _ ## Name ## _ ## Suffix

◆ CR_LANG

#define CR_LANG   CR_LANG_C

Definition at line 52 of file test.h.

◆ CR_SUITE_BASE

#define CR_SUITE_BASE ( Name,
... )
Value:
.file_ = __FILE__, \
.line_ = 0, \
__VA_ARGS__ \
)); \
struct criterion_suite CR_SUITE_IDENTIFIER_(Name, meta) = { \
#Name, \
&CR_SUITE_IDENTIFIER_(Name, extra), \
}; \
CR_ATTRIBUTE(used) \
CR_SECTION_("cr_sts") \
struct criterion_suite *CR_SUITE_IDENTIFIER_(Name, ptr) \
= &CR_SUITE_IDENTIFIER_(Name, meta) CR_SECTION_SUFFIX_
#define CRITERION_MAKE_STRUCT(Type,...)
#define CR_SUITE_IDENTIFIER_(Name, Suffix)
Definition test.h:64

Definition at line 182 of file test.h.

182#define CR_SUITE_BASE(Name, ...) \
183 struct criterion_test_extra_data CR_SUITE_IDENTIFIER_(Name, extra) = \
184 CR_EXPAND(CRITERION_MAKE_STRUCT(criterion_test_extra_data, \
185 .file_ = __FILE__, \
186 .line_ = 0, \
187 __VA_ARGS__ \
188 )); \
189 struct criterion_suite CR_SUITE_IDENTIFIER_(Name, meta) = { \
190 #Name, \
191 &CR_SUITE_IDENTIFIER_(Name, extra), \
192 }; \
193 CR_ATTRIBUTE(used) \
194 CR_SECTION_("cr_sts") \
195 struct criterion_suite *CR_SUITE_IDENTIFIER_(Name, ptr) \
196 = &CR_SUITE_IDENTIFIER_(Name, meta) CR_SECTION_SUFFIX_

◆ CR_SUITE_IDENTIFIER_

#define CR_SUITE_IDENTIFIER_ ( Name,
Suffix )    suite_ ## Name ## _ ## Suffix

Definition at line 64 of file test.h.

64#define CR_SUITE_IDENTIFIER_(Name, Suffix) \
65 suite_ ## Name ## _ ## Suffix

◆ CR_TEST_BASE

#define CR_TEST_BASE ( Category,
Name,
... )
Value:
CR_TEST_PROTOTYPE_(Category, Name); \
CR_TEST_TRAMPOLINE_(Category, Name) \
struct criterion_test_extra_data CR_IDENTIFIER_(Category, Name, extra) = \
.compiler_ = CR_COMPILER_, \
.lang_ = CR_LANG, \
.kind_ = CR_TEST_NORMAL, \
.param_ = (struct criterion_test_params (*)(void))NULL, \
.identifier_ = #Category "/" #Name, \
.file_ = __FILE__, \
.line_ = __LINE__, \
__VA_ARGS__ \
)); \
struct criterion_test CR_IDENTIFIER_(Category, Name, meta) = { \
#Name, \
#Category, \
CR_IDENTIFIER_(Category, Name, jmp), \
&CR_IDENTIFIER_(Category, Name, extra) \
}; \
CR_ATTRIBUTE(used) \
CR_SECTION_("cr_tst") \
struct criterion_test *CR_IDENTIFIER_(Category, Name, ptr) \
= &CR_IDENTIFIER_(Category, Name, meta) CR_SECTION_SUFFIX_; \
CR_TEST_PROTOTYPE_(Category, Name)
#define NULL
Definition gmacros.h:924
#define CR_LANG
Definition test.h:52
#define CR_TEST_PROTOTYPE_(Category, Name)
Definition test.h:60
#define CR_COMPILER_
Definition test.h:153
#define CR_IDENTIFIER_(Category, Name, Suffix)
Definition test.h:39
@ CR_TEST_NORMAL
Definition types.h:58

Definition at line 156 of file test.h.

156#define CR_TEST_BASE(Category, Name, ...) \
157 CR_TEST_PROTOTYPE_(Category, Name); \
158 CR_TEST_TRAMPOLINE_(Category, Name) \
159 struct criterion_test_extra_data CR_IDENTIFIER_(Category, Name, extra) = \
160 CR_EXPAND(CRITERION_MAKE_STRUCT(criterion_test_extra_data, \
161 .compiler_ = CR_COMPILER_, \
162 .lang_ = CR_LANG, \
163 .kind_ = CR_TEST_NORMAL, \
164 .param_ = (struct criterion_test_params (*)(void))NULL, \
165 .identifier_ = #Category "/" #Name, \
166 .file_ = __FILE__, \
167 .line_ = __LINE__, \
168 __VA_ARGS__ \
169 )); \
170 struct criterion_test CR_IDENTIFIER_(Category, Name, meta) = { \
171 #Name, \
172 #Category, \
173 CR_IDENTIFIER_(Category, Name, jmp), \
174 &CR_IDENTIFIER_(Category, Name, extra) \
175 }; \
176 CR_ATTRIBUTE(used) \
177 CR_SECTION_("cr_tst") \
178 struct criterion_test *CR_IDENTIFIER_(Category, Name, ptr) \
179 = &CR_IDENTIFIER_(Category, Name, meta) CR_SECTION_SUFFIX_; \
180 CR_TEST_PROTOTYPE_(Category, Name)

◆ CR_TEST_PROTOTYPE_

#define CR_TEST_PROTOTYPE_ ( Category,
Name )    void CR_IDENTIFIER_(Category, Name, impl)(void)

Definition at line 60 of file test.h.

60# define CR_TEST_PROTOTYPE_(Category, Name) \
61 void CR_IDENTIFIER_(Category, Name, impl)(void)

◆ CR_TEST_TRAMPOLINE_

#define CR_TEST_TRAMPOLINE_ ( Category,
Name )
Value:
static inline void CR_IDENTIFIER_(Category, Name, jmp)(void) { \
criterion_internal_test_setup(); \
criterion_internal_test_main((void (*)(void))CR_IDENTIFIER_(Category, Name, impl)); \
criterion_internal_test_teardown(); \
}

Definition at line 137 of file test.h.

137# define CR_TEST_TRAMPOLINE_(Category, Name) \
138 static inline void CR_IDENTIFIER_(Category, Name, jmp)(void) { \
139 criterion_internal_test_setup(); \
140 criterion_internal_test_main((void (*)(void))CR_IDENTIFIER_(Category, Name, impl)); \
141 criterion_internal_test_teardown(); \
142 }

◆ Test

#define Test ( ...)    CR_EXPAND(CR_TEST_BASE(__VA_ARGS__, .sentinel_ = 0))

Definition at line 199 of file test.h.

◆ TestSuite

#define TestSuite ( ...)    CR_EXPAND(CR_SUITE_BASE(__VA_ARGS__, .sentinel_ = 0))

Definition at line 201 of file test.h.

Function Documentation

◆ criterion_internal_test_main()

CR_API void criterion_internal_test_main ( void(*)(void) fn)

◆ criterion_internal_test_setup()

CR_BEGIN_C_API CR_API void criterion_internal_test_setup ( void )

◆ criterion_internal_test_teardown()

CR_API void criterion_internal_test_teardown ( void )

Variable Documentation

◆ cr_msg_test_fini_other_exception

const char* const cr_msg_test_fini_other_exception = "Caught some unexpected exception during the test finalization."
static

Definition at line 80 of file test.h.

◆ cr_msg_test_fini_std_exception

const char* const cr_msg_test_fini_std_exception = "Caught an unexpected exception during the test finalization: %s."
static

Definition at line 79 of file test.h.

◆ cr_msg_test_init_other_exception

const char* const cr_msg_test_init_other_exception = "Caught some unexpected exception during the test initialization."
static

Definition at line 76 of file test.h.

◆ cr_msg_test_init_std_exception

CR_END_C_API const char* const cr_msg_test_init_std_exception = "Caught an unexpected exception during the test initialization: %s."
static

Definition at line 75 of file test.h.

◆ cr_msg_test_main_other_exception

const char* const cr_msg_test_main_other_exception = "Caught some unexpected exception during the test execution."
static

Definition at line 78 of file test.h.

◆ cr_msg_test_main_std_exception

const char* const cr_msg_test_main_std_exception = "Caught an unexpected exception during the test execution: %s."
static

Definition at line 77 of file test.h.