From 83acbf7efdd47b20e3107cf2cba49f83a46606d3 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 8 Sep 2023 12:51:22 -0700 Subject: [PATCH] test: factor out verify_line() --- tl-append-test.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tl-append-test.c b/tl-append-test.c index 7e8455d..57ceb98 100644 --- a/tl-append-test.c +++ b/tl-append-test.c @@ -51,6 +51,11 @@ static ex_t write_to_tl_append(const char *content) { return expectation(start, end, content); } +static void verify_line(const ex_t *ex, const char *line) { + if (strncmp(ex->message, line, strlen(ex->message) + 1) != 0) + die("Wrong contents in log file"); +} + static void verify_log_contents(ex_t exps[]) { FILE *f = fopen(FILENAME, "r"); @@ -63,8 +68,7 @@ static void verify_log_contents(ex_t exps[]) { die("Error reading log file"); if (ferror(f)) die("Error reading log file"); - if (strncmp(exps[i].message, buf, len + 1) != 0) - die("Wrong contents in log file"); + verify_line(&exps[i], buf); free(buf); } if (fclose(f) != 0) -- 2.44.1