aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-05-10 19:29:22 +0200
committerDavid Robillard <d@drobilla.net>2019-04-13 19:15:32 +0200
commit38ab5fbb4dd2bc6cb24b80cc346546677f3d2813 (patch)
tree29e885fd426c0c8745b3daf72b18ca2e6380fcc8 /tests
parent19b358a447cf62da8aff1f4ef0235b04f39499eb (diff)
downloadserd-38ab5fbb4dd2bc6cb24b80cc346546677f3d2813.tar.gz
serd-38ab5fbb4dd2bc6cb24b80cc346546677f3d2813.tar.bz2
serd-38ab5fbb4dd2bc6cb24b80cc346546677f3d2813.zip
Add SerdSink interface and hide individual function implementations
Diffstat (limited to 'tests')
-rw-r--r--tests/serd_test.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c
index 90a01f03..e65692d6 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -425,9 +425,10 @@ main(void)
serd_writer_chop_blank_prefix(writer, "tmp");
serd_writer_chop_blank_prefix(writer, NULL);
- assert(serd_writer_set_base_uri(writer, lit));
- assert(serd_writer_set_prefix(writer, lit, lit));
- assert(serd_writer_end_anon(writer, NULL));
+ const SerdSink* iface = serd_writer_get_sink(writer);
+ assert(iface->base(iface->handle, lit));
+ assert(iface->prefix(iface->handle, lit, lit));
+ assert(iface->end(iface->handle, NULL));
assert(serd_writer_get_env(writer) == env);
uint8_t buf[] = { 0xEF, 0xBF, 0xBD, 0 };
@@ -447,8 +448,8 @@ main(void)
{ s, p, NULL },
{ NULL, NULL, NULL } };
for (unsigned i = 0; i < sizeof(junk) / (sizeof(SerdNode*) * 5); ++i) {
- assert(serd_writer_write_statement(
- writer, 0, NULL,
+ assert(iface->statement(
+ iface->handle, 0, NULL,
junk[i][0], junk[i][1], junk[i][2]));
}
@@ -465,27 +466,23 @@ main(void)
{ s, p, o },
{ s, p, o } };
for (unsigned i = 0; i < sizeof(good) / (sizeof(SerdNode*) * 5); ++i) {
- assert(!serd_writer_write_statement(
- writer, 0, NULL,
- good[i][0], good[i][1], good[i][2]));
+ assert(!iface->statement(
+ iface->handle, 0, NULL, good[i][0], good[i][1], good[i][2]));
}
// Write statements with bad UTF-8 (should be replaced)
const char bad_str[] = { (char)0xFF, (char)0x90, 'h', 'i', 0 };
SerdNode* bad_lit = serd_node_new_string(SERD_LITERAL, bad_str);
SerdNode* bad_uri = serd_node_new_string(SERD_URI, bad_str);
- assert(!serd_writer_write_statement(
- writer, 0, NULL, s, p, bad_lit));
- assert(!serd_writer_write_statement(writer, 0, NULL,
- s, p, bad_uri));
+ assert(!iface->statement(iface->handle, 0, NULL, s, p, bad_lit));
+ assert(!iface->statement(iface->handle, 0, NULL, s, p, bad_uri));
serd_node_free(bad_lit);
serd_node_free(bad_uri);
// Write 1 valid statement
serd_node_free(o);
o = serd_node_new_string(SERD_LITERAL, "hello");
- assert(!serd_writer_write_statement(writer, 0, NULL,
- s, p, o));
+ assert(!iface->statement(iface->handle, 0, NULL, s, p, o));
serd_writer_free(writer);
serd_node_free(lit);
@@ -514,11 +511,9 @@ main(void)
fseek(fd, 0, SEEK_SET);
ReaderTest* rt = (ReaderTest*)calloc(1, sizeof(ReaderTest));
- SerdReader* reader = serd_reader_new(
- SERD_TURTLE, rt, free,
- NULL, NULL, test_sink, NULL);
+ SerdSink sink = { rt, NULL, NULL, test_sink, NULL };
+ SerdReader* reader = serd_reader_new(SERD_TURTLE, &sink);
assert(reader);
- assert(serd_reader_get_handle(reader) == rt);
SerdNode* g = serd_node_new_string(SERD_URI, "http://example.org/");
serd_reader_set_default_graph(reader, g);
@@ -539,6 +534,7 @@ main(void)
assert(serd_reader_read_string(reader, "This isn't Turtle at all."));
serd_reader_free(reader);
+ free(rt);
fclose(fd);
serd_env_free(env);