mirror of https://git.tukaani.org/xz.git
Tests: tuktest.h: Move a printf from a macro to a helper function.
This commit is contained in:
parent
f9e8176ea7
commit
83d2337b72
|
@ -457,22 +457,32 @@ tuktest_run_test(void (*testfunc)(void), const char *testfunc_str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Internal helper that converts an enum tuktest_result value to a string.
|
// Internal helper that prints the prefix of the fail/skip/error message line.
|
||||||
static const char *
|
static void
|
||||||
tuktest_result_str(enum tuktest_result result)
|
tuktest_print_result_prefix(enum tuktest_result result,
|
||||||
|
const char *filename, unsigned line)
|
||||||
{
|
{
|
||||||
return result == TUKTEST_PASS ? TUKTEST_STR_PASS
|
// This is never called with TUKTEST_PASS but I kept it here anyway.
|
||||||
: (result) == TUKTEST_FAIL ? TUKTEST_STR_FAIL
|
const char *result_str
|
||||||
: (result) == TUKTEST_SKIP ? TUKTEST_STR_SKIP
|
= result == TUKTEST_PASS ? TUKTEST_STR_PASS
|
||||||
|
: result == TUKTEST_FAIL ? TUKTEST_STR_FAIL
|
||||||
|
: result == TUKTEST_SKIP ? TUKTEST_STR_SKIP
|
||||||
: TUKTEST_STR_ERROR;
|
: TUKTEST_STR_ERROR;
|
||||||
|
|
||||||
|
const char *short_filename = tuktest_basename(filename);
|
||||||
|
|
||||||
|
if (tuktest_name != NULL)
|
||||||
|
printf("%s %s [%s:%u] ", result_str, tuktest_name,
|
||||||
|
short_filename, line);
|
||||||
|
else
|
||||||
|
printf("%s [%s:%u] ", result_str, short_filename, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Internal helper for assert_fail, assert_skip, and assert_error.
|
// Internal helper for assert_fail, assert_skip, and assert_error.
|
||||||
#define tuktest_print_and_jump(result, ...) \
|
#define tuktest_print_and_jump(result, ...) \
|
||||||
do { \
|
do { \
|
||||||
printf("%s %s [%s:%u] ", tuktest_result_str(result), tuktest_name, \
|
tuktest_print_result_prefix(result, __FILE__, __LINE__); \
|
||||||
tuktest_basename(__FILE__), __LINE__); \
|
|
||||||
printf(__VA_ARGS__); \
|
printf(__VA_ARGS__); \
|
||||||
printf("\n"); \
|
printf("\n"); \
|
||||||
longjmp(tuktest_jmpenv, result); \
|
longjmp(tuktest_jmpenv, result); \
|
||||||
|
|
Loading…
Reference in New Issue