aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-02-28 23:26:12 -0500
committerDavid Robillard <d@drobilla.net>2021-03-08 23:23:05 -0500
commit2824a66adfec03a242f8df8b855af2061b39c13d (patch)
treef92480da04bdc0277ec6b9a7cc53334374a20cf1 /test
parent42ac3e7a0516b4c5d3b13a4cb842ab3f3d368101 (diff)
downloadserd-2824a66adfec03a242f8df8b855af2061b39c13d.tar.gz
serd-2824a66adfec03a242f8df8b855af2061b39c13d.tar.bz2
serd-2824a66adfec03a242f8df8b855af2061b39c13d.zip
Fix socket-like stream reading test
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;
}