summaryrefslogtreecommitdiff
path: root/tests/str_table.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-09-25 21:06:59 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-09-29 18:19:53 +0200
commit4b4cee0c0c99f531a45157fd27f5441e511db109 (patch)
tree825aae023f27c2f578536af35dfd01b1dc96e18e /tests/str_table.c
parentd87bffd89b9c0a26a65f0c629250fa87902b6cb8 (diff)
Replace file/getline usage with istream
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tests/str_table.c')
-rw-r--r--tests/str_table.c29
1 files changed, 7 insertions, 22 deletions
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)