aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_reader_writer.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index f4fa6127..f526a68c 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -39,19 +39,21 @@ count_statements(void* handle, const SerdEvent* event)
static size_t
eof_test_read(void* buf, size_t size, size_t nmemb, void* stream)
{
- assert(nmemb == 1);
+ assert(size == 1);
+ (void)size;
static const char* const string = "_:s1 <http://example.org/p> _:o1 .\n"
"_:s2 <http://example.org/p> _:o2 .\n";
size_t* count = (size_t*)stream;
- if (*count == 34 || *count == 35 || *count + nmemb >= strlen(string)) {
+ if (*count == 34 || *count == 35 || *count + nmemb >= strlen(string) + 2) {
++*count;
return 0;
}
- memcpy((char*)buf, string + *count, size * nmemb);
+ *(char*)buf = string[*count - (*count > 35 ? 2 : 0)];
*count += nmemb;
+
return nmemb;
}