From 4b4cee0c0c99f531a45157fd27f5441e511db109 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 25 Sep 2020 21:06:59 +0200 Subject: Replace file/getline usage with istream Signed-off-by: David Oberhollenzer --- tests/str_table.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'tests/str_table.c') diff --git a/tests/str_table.c b/tests/str_table.c index 0935c89..7bcf4cc 100644 --- a/tests/str_table.c +++ b/tests/str_table.c @@ -7,46 +7,31 @@ #include "config.h" #include "str_table.h" +#include "fstream.h" #include "compat.h" #include "test.h" -#define STR(x) #x -#define STRVALUE(x) STR(x) - -#define TEST_PATH STRVALUE(TESTPATH) - static char *strings[1000]; static int read_strings(void) { + istream_t *fp; ssize_t ret; char *line; - size_t n; - FILE *fp; int i; - fp = test_open_read("words.txt"); + fp = istream_open_file("words.txt"); + TEST_NOT_NULL(fp); for (i = 0; i < 1000; ++i) { - line = NULL; - n = 0; - - ret = getline(&line, &n, fp); - if (ret < 0) { - perror("reading words"); - goto fail; - } + ret = istream_get_line(fp, &line, NULL, 0); + TEST_EQUAL_I(ret, 0); strings[i] = line; } - fclose(fp); + sqfs_destroy(fp); return 0; -fail: - for (i = 0; i < 1000; ++i) - free(strings[i]); - fclose(fp); - return -1; } int main(void) -- cgit v1.2.3