Fixed decoupling for parameterized tests and fixed missing definitions
This commit is contained in:
parent
30c3afedda
commit
f913940427
6 changed files with 60 additions and 57 deletions
|
@ -147,6 +147,7 @@ set(SOURCE_FILES
|
|||
src/core/stats.c
|
||||
src/core/stats.h
|
||||
src/core/ordered-set.c
|
||||
src/core/test.c
|
||||
src/compat/internal.h
|
||||
src/compat/pipe.c
|
||||
src/compat/pipe.h
|
||||
|
|
|
@ -31,6 +31,8 @@ CR_BEGIN_C_API
|
|||
CR_API CR_NORETURN void criterion_abort_test(void);
|
||||
CR_INLINE static void criterion_continue_test(void) {}
|
||||
|
||||
CR_API void criterion_test_die(const char *msg, ...);
|
||||
|
||||
CR_END_C_API
|
||||
|
||||
#endif /* !CRITERION_ABORT_H_ */
|
||||
|
|
|
@ -79,6 +79,7 @@ struct criterion_test_params {
|
|||
|
||||
# define CR_PARAM_TEST_BASE(Param, Category, Name, ...) \
|
||||
CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name); \
|
||||
CR_TEST_TRAMPOLINE_(Category, Name) \
|
||||
struct criterion_test_extra_data CR_IDENTIFIER_(Category, Name, extra) = \
|
||||
CR_EXPAND(CRITERION_MAKE_STRUCT(criterion_test_extra_data, \
|
||||
.lang_ = CR_LANG, \
|
||||
|
@ -92,7 +93,7 @@ struct criterion_test_params {
|
|||
struct criterion_test CR_IDENTIFIER_(Category, Name, meta) = { \
|
||||
#Name, \
|
||||
#Category, \
|
||||
(void(*)(void)) CR_IDENTIFIER_(Category, Name, impl), \
|
||||
CR_IDENTIFIER_(Category, Name, jmp), \
|
||||
&CR_IDENTIFIER_(Category, Name, extra) \
|
||||
}; \
|
||||
CR_SECTION_("cr_tst") \
|
||||
|
|
|
@ -79,65 +79,65 @@ static const char *const cr_msg_test_fini_std_exception = "Caught an unexpected
|
|||
static const char *const cr_msg_test_fini_other_exception = "Caught some unexpected exception during the test finalization.";
|
||||
|
||||
# ifdef __cplusplus
|
||||
# define CR_TEST_TRAMPOLINE_(Category, Name) \
|
||||
static inline void CR_IDENTIFIER_(Category, Name, jmp)(void) { \
|
||||
try { \
|
||||
criterion_internal_test_setup(); \
|
||||
} catch (const std::exception &e) { \
|
||||
criterion_test_die(cr_msg_test_init_std_exception, e.what()); \
|
||||
} catch (...) { \
|
||||
criterion_test_die(cr_msg_test_init_other_exception); \
|
||||
} \
|
||||
try { \
|
||||
criterion_internal_test_main(CR_IDENTIFIER_(Category, Name, impl)); \
|
||||
} catch (const std::exception &e) { \
|
||||
criterion_test_die(cr_msg_test_main_std_exception, e.what()); \
|
||||
} catch (...) { \
|
||||
criterion_test_die(cr_msg_test_main_other_exception); \
|
||||
} \
|
||||
try { \
|
||||
criterion_internal_test_teardown(); \
|
||||
} catch (const std::exception &e) { \
|
||||
criterion_test_die(cr_msg_test_fini_std_exception, e.what()); \
|
||||
} catch (...) { \
|
||||
criterion_test_die(cr_msg_test_fini_other_exception); \
|
||||
} \
|
||||
# define CR_TEST_TRAMPOLINE_(Category, Name) \
|
||||
static inline void CR_IDENTIFIER_(Category, Name, jmp)(void) { \
|
||||
try { \
|
||||
criterion_internal_test_setup(); \
|
||||
} catch (const std::exception &e) { \
|
||||
criterion_test_die(cr_msg_test_init_std_exception, e.what()); \
|
||||
} catch (...) { \
|
||||
criterion_test_die(cr_msg_test_init_other_exception); \
|
||||
} \
|
||||
try { \
|
||||
criterion_internal_test_main((void(*)(void)) CR_IDENTIFIER_(Category, Name, impl)); \
|
||||
} catch (const std::exception &e) { \
|
||||
criterion_test_die(cr_msg_test_main_std_exception, e.what()); \
|
||||
} catch (...) { \
|
||||
criterion_test_die(cr_msg_test_main_other_exception); \
|
||||
} \
|
||||
try { \
|
||||
criterion_internal_test_teardown(); \
|
||||
} catch (const std::exception &e) { \
|
||||
criterion_test_die(cr_msg_test_fini_std_exception, e.what()); \
|
||||
} catch (...) { \
|
||||
criterion_test_die(cr_msg_test_fini_other_exception); \
|
||||
} \
|
||||
}
|
||||
# else
|
||||
# if defined(__OBJC__) && defined(__EXCEPTIONS)
|
||||
# define CR_TEST_TRAMPOLINE_(Category, Name) \
|
||||
static inline void CR_IDENTIFIER_(Category, Name, jmp)(void) { \
|
||||
@try { \
|
||||
criterion_internal_test_setup(); \
|
||||
} @catch (NSException *e) { \
|
||||
NSString *reason = [e reason]; \
|
||||
criterion_test_die(cr_msg_test_init_std_exception, [reason UTF8String]); \
|
||||
} @catch (...) { \
|
||||
criterion_test_die(cr_msg_test_init_other_exception); \
|
||||
} \
|
||||
@try { \
|
||||
criterion_internal_test_main(CR_IDENTIFIER_(Category, Name, impl)); \
|
||||
} @catch (NSException *e) { \
|
||||
NSString *reason = [e reason]; \
|
||||
criterion_test_die(cr_msg_test_main_std_exception, [reason UTF8String]); \
|
||||
} @catch (...) { \
|
||||
criterion_test_die(cr_msg_test_main_other_exception); \
|
||||
} \
|
||||
@try { \
|
||||
criterion_internal_test_teardown(); \
|
||||
} @catch (NSException *e) { \
|
||||
NSString *reason = [e reason]; \
|
||||
criterion_test_die(cr_msg_test_fini_std_exception, [reason UTF8String]); \
|
||||
} @catch (...) { \
|
||||
criterion_test_die(cr_msg_test_fini_other_exception); \
|
||||
} \
|
||||
# define CR_TEST_TRAMPOLINE_(Category, Name) \
|
||||
static inline void CR_IDENTIFIER_(Category, Name, jmp)(void) { \
|
||||
@try { \
|
||||
criterion_internal_test_setup(); \
|
||||
} @catch (NSException *e) { \
|
||||
NSString *reason = [e reason]; \
|
||||
criterion_test_die(cr_msg_test_init_std_exception, [reason UTF8String]); \
|
||||
} @catch (...) { \
|
||||
criterion_test_die(cr_msg_test_init_other_exception); \
|
||||
} \
|
||||
@try { \
|
||||
criterion_internal_test_main((void(*)(void)) CR_IDENTIFIER_(Category, Name, impl)); \
|
||||
} @catch (NSException *e) { \
|
||||
NSString *reason = [e reason]; \
|
||||
criterion_test_die(cr_msg_test_main_std_exception, [reason UTF8String]); \
|
||||
} @catch (...) { \
|
||||
criterion_test_die(cr_msg_test_main_other_exception); \
|
||||
} \
|
||||
@try { \
|
||||
criterion_internal_test_teardown(); \
|
||||
} @catch (NSException *e) { \
|
||||
NSString *reason = [e reason]; \
|
||||
criterion_test_die(cr_msg_test_fini_std_exception, [reason UTF8String]); \
|
||||
} @catch (...) { \
|
||||
criterion_test_die(cr_msg_test_fini_other_exception); \
|
||||
} \
|
||||
}
|
||||
# else
|
||||
# define CR_TEST_TRAMPOLINE_(Category, Name) \
|
||||
static inline void CR_IDENTIFIER_(Category, Name, jmp)(void) { \
|
||||
criterion_internal_test_setup(); \
|
||||
criterion_internal_test_main(CR_IDENTIFIER_(Category, Name, impl)); \
|
||||
criterion_internal_test_teardown(); \
|
||||
# define CR_TEST_TRAMPOLINE_(Category, Name) \
|
||||
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(); \
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
|
|
@ -29,6 +29,4 @@
|
|||
|
||||
extern jmp_buf g_pre_test;
|
||||
|
||||
void criterion_test_die(const char *msg, ...);
|
||||
|
||||
#endif /* !ABORT_H_ */
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#include "criterion/internal/test.h"
|
||||
#include "core/abort.h"
|
||||
#include "core/stats.h"
|
||||
#include "core/worker.h"
|
||||
|
|
Loading…
Add table
Reference in a new issue