From: Scott Worley Date: Fri, 8 Sep 2023 19:51:22 +0000 (-0700) Subject: test: factor out verify_line() X-Git-Tag: v1.0.0~15 X-Git-Url: http://git.scottworley.com/tl-append/commitdiff_plain/83acbf7efdd47b20e3107cf2cba49f83a46606d3?ds=sidebyside test: factor out verify_line() --- 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)