aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-08-03 12:31:51 -0400
committerDavid Robillard <d@drobilla.net>2024-08-03 14:21:47 -0400
commitebe0b8697bca69abb7e7be1c731da4d54b10e462 (patch)
tree73f5b777ab632b2001a132eea82cd97499f330fa /test
parentf73aae2f97d1faa8e41a8b8627e1e186a1f900f4 (diff)
downloadserd-ebe0b8697bca69abb7e7be1c731da4d54b10e462.tar.gz
serd-ebe0b8697bca69abb7e7be1c731da4d54b10e462.tar.bz2
serd-ebe0b8697bca69abb7e7be1c731da4d54b10e462.zip
Fix reading chunks from files without trailing newlines
Diffstat (limited to 'test')
-rw-r--r--test/test_reader.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/test/test_reader.c b/test/test_reader.c
index cfaa8bed..18794f9e 100644
--- a/test/test_reader.c
+++ b/test/test_reader.c
@@ -219,6 +219,7 @@ test_read_eof_by_byte(void)
assert(serd_reader_read_chunk(reader) == SERD_SUCCESS);
assert(serd_reader_read_chunk(reader) == SERD_FAILURE);
+ serd_reader_end_stream(reader);
serd_reader_free(reader);
}
@@ -243,7 +244,7 @@ test_read_nquads_chunks(const char* const path)
fprintf(f,
"<http://example.org/s> <http://example.org/p3> "
- "<http://example.org/o3> .\n");
+ "<http://example.org/o3> .");
fseek(f, 0, SEEK_SET);
@@ -260,7 +261,9 @@ test_read_nquads_chunks(const char* const path)
assert(serd_reader_get_handle(reader) == &rt);
assert(f);
- SerdStatus st = serd_reader_start_stream(reader, f, NULL, false);
+ SerdStatus st = serd_reader_start_source_stream(
+ reader, (SerdSource)fread, (SerdStreamErrorFunc)ferror, f, NULL, 32U);
+
assert(st == SERD_SUCCESS);
// Read first statement
@@ -304,7 +307,7 @@ test_read_nquads_chunks(const char* const path)
assert(rt.n_end == 0);
assert(serd_reader_read_chunk(reader) == SERD_FAILURE);
-
+ serd_reader_end_stream(reader);
serd_reader_free(reader);
fclose(f);
remove(path);
@@ -323,8 +326,7 @@ test_read_turtle_chunks(const char* const path)
fprintf(f, "eg:s eg:p1 eg:o1 ;\n");
fprintf(f, " eg:p2 eg:o2 .\n");
fwrite(&null, sizeof(null), 1, f);
- fprintf(f, "eg:s eg:p [ eg:sp eg:so ] .\n");
- fwrite(&null, sizeof(null), 1, f);
+ fprintf(f, "eg:s eg:p [ eg:sp eg:so ] .");
fseek(f, 0, SEEK_SET);
ReaderTest rt = {0, 0, 0, 0};
@@ -340,7 +342,8 @@ test_read_turtle_chunks(const char* const path)
assert(serd_reader_get_handle(reader) == &rt);
assert(f);
- SerdStatus st = serd_reader_start_stream(reader, f, NULL, false);
+ SerdStatus st = serd_reader_start_source_stream(
+ reader, (SerdSource)fread, (SerdStreamErrorFunc)ferror, f, NULL, 32U);
assert(st == SERD_SUCCESS);
// Read base
@@ -400,7 +403,7 @@ test_read_turtle_chunks(const char* const path)
assert(rt.n_end == 1);
assert(serd_reader_read_chunk(reader) == SERD_FAILURE);
-
+ serd_reader_end_stream(reader);
serd_reader_free(reader);
fclose(f);
remove(path);