From 802e46f8ea36c344f112d7e1dd8d64d17a4cc939 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Mon, 15 Sep 2025 12:59:37 +0200 Subject: Run clang-format again --- tap/tap.c | 25 +++++++++++++++++-------- tap/tap.h | 43 ++++++++++++++++++++++++------------------- 2 files changed, 41 insertions(+), 27 deletions(-) (limited to 'tap') diff --git a/tap/tap.c b/tap/tap.c index 00ceab27..fb40736f 100644 --- a/tap/tap.c +++ b/tap/tap.c @@ -65,7 +65,8 @@ static void _cleanup(void); * test_name -- the name of the test, may be NULL * test_comment -- a comment to print afterwards, may be NULL */ -unsigned int _gen_result(int ok, const char *func, char *file, unsigned int line, char *test_name, ...) { +unsigned int _gen_result(int ok, const char *func, char *file, unsigned int line, char *test_name, + ...) { va_list ap; char *local_test_name = NULL; char *c; @@ -95,7 +96,9 @@ unsigned int _gen_result(int ok, const char *func, char *file, unsigned int line } if (name_is_digits) { - diag(" You named your test '%s'. You shouldn't use numbers for your test names.", local_test_name); + diag( + " You named your test '%s'. You shouldn't use numbers for your test names.", + local_test_name); diag(" Very confusing."); } } @@ -116,8 +119,9 @@ unsigned int _gen_result(int ok, const char *func, char *file, unsigned int line if (local_test_name != NULL) { flockfile(stdout); for (c = local_test_name; *c != '\0'; c++) { - if (*c == '#') + if (*c == '#') { fputc('\\', stdout); + } fputc((int)*c, stdout); } funlockfile(stdout); @@ -135,14 +139,16 @@ unsigned int _gen_result(int ok, const char *func, char *file, unsigned int line the test failed. */ if (todo) { printf(" # TODO %s", todo_msg ? todo_msg : todo_msg_fixed); - if (!ok) + if (!ok) { failures--; + } } printf("\n"); - if (!ok) + if (!ok) { diag(" Failed %stest (%s:%s() at line %d)", todo ? "(TODO) " : "", file, func, line); + } free(local_test_name); @@ -212,8 +218,9 @@ int plan_skip_all(char *reason) { printf("1..0"); - if (reason != NULL) + if (reason != NULL) { printf(" # Skip %s", reason); + } printf("\n"); @@ -294,7 +301,8 @@ int skip(unsigned int n, char *fmt, ...) { while (n-- > 0) { test_count++; - printf("ok %d # skip %s\n", test_count, skip_msg != NULL ? skip_msg : "libtap():malloc() failed"); + printf("ok %d # skip %s\n", test_count, + skip_msg != NULL ? skip_msg : "libtap():malloc() failed"); } free(skip_msg); @@ -396,8 +404,9 @@ void _cleanup(void) { return; } - if (failures) + if (failures) { diag("Looks like you failed %d tests of %d.", failures, test_count); + } UNLOCK; } diff --git a/tap/tap.h b/tap/tap.h index 5abbd76a..0c550bfd 100644 --- a/tap/tap.h +++ b/tap/tap.h @@ -28,45 +28,50 @@ and requires the caller to add the final comma if they've omitted the optional arguments */ #ifdef __GNUC__ -# define ok(e, test, ...) \ - ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, test, ##__VA_ARGS__) \ +# define ok(e, test, ...) \ + ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, test, ##__VA_ARGS__) \ : _gen_result(0, __func__, __FILE__, __LINE__, test, ##__VA_ARGS__)) -# define ok1(e) ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e)) +# define ok1(e) \ + ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) \ + : _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e)) # define pass(test, ...) ok(1, test, ##__VA_ARGS__); # define fail(test, ...) ok(0, test, ##__VA_ARGS__); -# define skip_start(test, n, fmt, ...) \ - do { \ - if ((test)) { \ - skip(n, fmt, ##__VA_ARGS__); \ - continue; \ +# define skip_start(test, n, fmt, ...) \ + do { \ + if ((test)) { \ + skip(n, fmt, ##__VA_ARGS__); \ + continue; \ } #else /* __GNUC__ */ /* The original tap.h used to test if __STDC_VERSION__ >= 199901L here. This * doesn't seem to work on HP-UX even though the code compile fine. I'm not * sure how to add an exception here for HP-UX so I just removed the check * for now */ -# define ok(e, ...) \ - ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, __VA_ARGS__) : _gen_result(0, __func__, __FILE__, __LINE__, __VA_ARGS__)) +# define ok(e, ...) \ + ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, __VA_ARGS__) \ + : _gen_result(0, __func__, __FILE__, __LINE__, __VA_ARGS__)) -# define ok1(e) ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e)) +# define ok1(e) \ + ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) \ + : _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e)) # define pass(...) ok(1, __VA_ARGS__); # define fail(...) ok(0, __VA_ARGS__); -# define skip_start(test, n, ...) \ - do { \ - if ((test)) { \ - skip(n, __VA_ARGS__); \ - continue; \ +# define skip_start(test, n, ...) \ + do { \ + if ((test)) { \ + skip(n, __VA_ARGS__); \ + continue; \ } #endif /* __GNUC__ */ -#define skip_end \ - } \ - while (0) \ +#define skip_end \ + } \ + while (0) \ ; unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...); -- cgit v1.2.3-74-g34f1