From f73aae2f97d1faa8e41a8b8627e1e186a1f900f4 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 3 Aug 2024 12:31:27 -0400 Subject: Cover bulk and byte-wise reading in reader EOF test --- test/test_reader.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'test/test_reader.c') 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)); -- cgit v1.2.1