aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-06-15 09:26:17 -0400
committerDavid Robillard <d@drobilla.net>2023-12-02 16:27:02 -0500
commitb631e7a3d6a807aaf4919396b62ba96e1a9f0bd9 (patch)
tree70a49bcc4d79d83d0f80f115da457514e09977d0 /test
parentfe0b6d5d4d78cb31e1bf2381198890d070e46ed1 (diff)
downloadserd-b631e7a3d6a807aaf4919396b62ba96e1a9f0bd9.tar.gz
serd-b631e7a3d6a807aaf4919396b62ba96e1a9f0bd9.tar.bz2
serd-b631e7a3d6a807aaf4919396b62ba96e1a9f0bd9.zip
Bring read/write interface closer to the C standard
Diffstat (limited to 'test')
-rw-r--r--test/test_reader_writer.c21
-rw-r--r--test/test_writer.c13
2 files changed, 24 insertions, 10 deletions
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index 9183af5c..3b656c2e 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -374,21 +374,27 @@ test_read_string(void)
}
static size_t
-faulty_sink(const void* const buf, const size_t len, void* const stream)
+faulty_sink(const void* const buf,
+ const size_t size,
+ const size_t nmemb,
+ void* const stream)
{
(void)buf;
- (void)len;
+ (void)size;
+ (void)nmemb;
+
+ assert(size == 1);
ErrorContext* const ctx = (ErrorContext*)stream;
- const size_t new_n_written = ctx->n_written + len;
+ const size_t new_n_written = ctx->n_written + nmemb;
if (new_n_written >= ctx->error_offset) {
errno = EINVAL;
return 0U;
}
- ctx->n_written += len;
+ ctx->n_written += nmemb;
errno = 0;
- return len;
+ return nmemb;
}
static SerdStatus
@@ -448,7 +454,8 @@ test_writer(const char* const path)
SerdEnv* env = serd_env_new(serd_empty_string());
assert(fd);
- SerdWriter* writer = serd_writer_new(SERD_TURTLE, 0, env, serd_file_sink, fd);
+ SerdWriter* writer =
+ serd_writer_new(SERD_TURTLE, 0, env, (SerdWriteFunc)fwrite, fd);
assert(writer);
serd_writer_chop_blank_prefix(writer, "tmp");
@@ -595,7 +602,7 @@ test_reader(const char* path)
{
size_t n_reads = 0;
serd_reader_start_source_stream(reader,
- (SerdSource)eof_test_read,
+ (SerdReadFunc)eof_test_read,
(SerdStreamErrorFunc)eof_test_error,
&n_reads,
NULL,
diff --git a/test/test_writer.c b/test/test_writer.c
index 76d046d7..0c78495e 100644
--- a/test/test_writer.c
+++ b/test/test_writer.c
@@ -77,12 +77,15 @@ test_write_long_literal(void)
}
static size_t
-null_sink(const void* const buf, const size_t len, void* const stream)
+null_sink(const void* const buf,
+ const size_t size,
+ const size_t nmemb,
+ void* const stream)
{
(void)buf;
(void)stream;
- return len;
+ return size * nmemb;
}
static void
@@ -167,9 +170,13 @@ test_strict_write(void)
// Produce a write error without setting errno
static size_t
-error_sink(const void* const buf, const size_t len, void* const stream)
+error_sink(const void* const buf,
+ const size_t size,
+ const size_t len,
+ void* const stream)
{
(void)buf;
+ (void)size;
(void)len;
(void)stream;
return 0U;