aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-08-03 12:31:27 -0400
committerDavid Robillard <d@drobilla.net>2024-08-03 14:21:47 -0400
commitf73aae2f97d1faa8e41a8b8627e1e186a1f900f4 (patch)
treee2b38ed0cb5f0f19b754d3f2dc094bc452d2d41c
parent760720b1f762be629841b4d0a32f17aab2ee44f2 (diff)
downloadserd-f73aae2f97d1faa8e41a8b8627e1e186a1f900f4.tar.gz
serd-f73aae2f97d1faa8e41a8b8627e1e186a1f900f4.tar.bz2
serd-f73aae2f97d1faa8e41a8b8627e1e186a1f900f4.zip
Cover bulk and byte-wise reading in reader EOF test
-rw-r--r--test/test_reader.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/test/test_reader.c b/test/test_reader.c
index b102f8a6..cfaa8bed 100644
--- a/test/test_reader.c
+++ b/test/test_reader.c
@@ -155,9 +155,9 @@ eof_test_error(void* stream)
return 0;
}
-/// A read of a big page hits EOF then fails to read chunks immediately
+/// A read of a file stream hits EOF then fails to read chunks immediately
static void
-test_read_eof_by_page(const char* const path)
+test_read_eof_file(const char* const path)
{
FILE* const f = fopen(path, "w+b");
assert(f);
@@ -175,13 +175,20 @@ test_read_eof_by_page(const char* const path)
test_statement_sink,
test_end_sink);
+ fseek(f, 0L, SEEK_SET);
serd_reader_start_stream(reader, f, (const uint8_t*)"test", true);
-
assert(serd_reader_read_chunk(reader) == SERD_SUCCESS);
assert(serd_reader_read_chunk(reader) == SERD_FAILURE);
assert(serd_reader_read_chunk(reader) == SERD_FAILURE);
+ serd_reader_end_stream(reader);
+ fseek(f, 0L, SEEK_SET);
+ serd_reader_start_stream(reader, f, (const uint8_t*)"test", false);
+ assert(serd_reader_read_chunk(reader) == SERD_SUCCESS);
+ assert(serd_reader_read_chunk(reader) == SERD_FAILURE);
+ assert(serd_reader_read_chunk(reader) == SERD_FAILURE);
serd_reader_end_stream(reader);
+
serd_reader_free(reader);
fclose(f);
}
@@ -428,7 +435,7 @@ main(void)
test_read_turtle_chunks(path);
test_read_string();
- test_read_eof_by_page(path);
+ test_read_eof_file(path);
test_read_eof_by_byte();
assert(!remove(path));