aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_read_chunk.c38
-rw-r--r--test/test_reader_writer.c19
2 files changed, 25 insertions, 32 deletions
diff --git a/test/test_read_chunk.c b/test/test_read_chunk.c
index dd2961ac..76e9b642 100644
--- a/test/test_read_chunk.c
+++ b/test/test_read_chunk.c
@@ -19,8 +19,7 @@
#include "serd/serd.h"
#include <assert.h>
-#include <stdbool.h>
-#include <stdio.h>
+#include <stddef.h>
static size_t n_base = 0;
static size_t n_prefix = 0;
@@ -80,39 +79,32 @@ on_end(void* handle, const SerdNode* node)
int
main(void)
{
- FILE* file = tmpfile();
-
- fprintf(file,
- "@prefix eg: <http://example.org/> .\n"
- "@base <http://example.org/base> .\n"
- "eg:s1 eg:p1 eg:o1 ;\n"
- " eg:p2 eg:o2 ,\n"
- " eg:o3 .\n"
- "eg:s2 eg:p1 eg:o1 ;\n"
- " eg:p2 eg:o2 .\n"
- "eg:s3 eg:p1 eg:o1 .\n"
- "eg:s4 eg:p1 [ eg:p3 eg:o1 ] .\n");
-
- fseek(file, 0, SEEK_SET);
-
SerdReader* reader = serd_reader_new(
SERD_TURTLE, NULL, NULL, on_base, on_prefix, on_statement, on_end);
-
assert(reader);
- assert(!serd_reader_start_stream(reader, file, NULL, true));
+
+ assert(!serd_reader_start_string(reader,
+ "@prefix eg: <http://example.org/> .\n"
+ "@base <http://example.org/base> .\n"
+ "eg:s1 eg:p1 eg:o1 ;\n"
+ " eg:p2 eg:o2 ,\n"
+ " eg:o3 .\n"
+ "eg:s2 eg:p1 eg:o1 ;\n"
+ " eg:p2 eg:o2 .\n"
+ "eg:s3 eg:p1 eg:o1 .\n"
+ "eg:s4 eg:p1 [ eg:p3 eg:o1 ] .\n"));
assert(!serd_reader_read_chunk(reader) && n_prefix == 1);
assert(!serd_reader_read_chunk(reader) && n_base == 1);
assert(!serd_reader_read_chunk(reader) && n_statement == 3);
assert(!serd_reader_read_chunk(reader) && n_statement == 5);
assert(!serd_reader_read_chunk(reader) && n_statement == 6);
- assert(!serd_reader_read_chunk(reader) && n_statement == 8 && n_end == 1);
+ assert(!serd_reader_read_chunk(reader) && n_statement == 8);
assert(serd_reader_read_chunk(reader) == SERD_FAILURE);
+ assert(n_end == 1);
assert(serd_reader_read_chunk(reader) == SERD_FAILURE);
-
assert(!serd_reader_end_stream(reader));
- serd_reader_free(reader);
- fclose(file);
+ serd_reader_free(reader);
return 0;
}
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index 5431462a..48bb508e 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -19,7 +19,6 @@
#include "serd/serd.h"
#include <assert.h>
-#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -89,7 +88,8 @@ test_read_chunks(void)
assert(serd_reader_handle(reader) == rt);
assert(f);
- SerdStatus st = serd_reader_start_stream(reader, f, NULL, false);
+ SerdStatus st = serd_reader_start_stream(
+ reader, (SerdSource)fread, (SerdStreamErrorFunc)ferror, f, NULL, 1);
assert(st == SERD_SUCCESS);
// Write two statement separated by null characters
@@ -292,7 +292,8 @@ test_reader(const char* path)
fflush(temp);
fseek(temp, 0L, SEEK_SET);
- serd_reader_start_stream(reader, temp, NULL, true);
+ serd_reader_start_stream(
+ reader, (SerdSource)fread, (SerdStreamErrorFunc)ferror, temp, NULL, 4096);
assert(serd_reader_read_chunk(reader) == SERD_SUCCESS);
assert(serd_reader_read_chunk(reader) == SERD_FAILURE);
@@ -305,12 +306,12 @@ test_reader(const char* path)
// A byte-wise reader that hits EOF once then continues (like a socket)
{
size_t n_reads = 0;
- serd_reader_start_source_stream(reader,
- (SerdSource)eof_test_read,
- (SerdStreamErrorFunc)eof_test_error,
- &n_reads,
- NULL,
- 1);
+ serd_reader_start_stream(reader,
+ (SerdSource)eof_test_read,
+ (SerdStreamErrorFunc)eof_test_error,
+ &n_reads,
+ NULL,
+ 1);
assert(serd_reader_read_chunk(reader) == SERD_SUCCESS);
assert(serd_reader_read_chunk(reader) == SERD_FAILURE);