From 7269c12bbe4532f5f5844aaec16cf1bb75a1c71c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 15 Apr 2021 17:52:44 -0400 Subject: Expand URIs in reader This expands relative and prefixed URIs in the reader on the stack, rather than passing them to the caller to be dealt with. This pushes these context-full forms to the edge of the system as much as possible to minimise the headaches they can cause. Towards having stricter guarantees about nodes and eliminating the CURIE node type altogether. --- test/test_writer.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test/test_writer.c') diff --git a/test/test_writer.c b/test/test_writer.c index dc1ebfcb..0ced87d6 100644 --- a/test/test_writer.c +++ b/test/test_writer.c @@ -286,6 +286,41 @@ test_write_empty_syntax(void) serd_world_free(world); } +static void +test_write_bad_uri(void) +{ + SerdWorld* world = serd_world_new(); + SerdNodes* nodes = serd_world_nodes(world); + SerdEnv* env = serd_env_new(SERD_EMPTY_STRING()); + + const SerdNode* s = + serd_nodes_uri(nodes, SERD_STRING("http://example.org/s")); + + const SerdNode* p = + serd_nodes_uri(nodes, SERD_STRING("http://example.org/p")); + + const SerdNode* rel = serd_nodes_uri(nodes, SERD_STRING("rel")); + + SerdBuffer buffer = {NULL, 0}; + SerdByteSink* byte_sink = serd_byte_sink_new_buffer(&buffer); + + SerdWriter* writer = + serd_writer_new(world, SERD_NTRIPLES, 0u, env, byte_sink); + + assert(writer); + + const SerdStatus st = + serd_sink_write(serd_writer_sink(writer), 0u, s, p, rel, NULL); + assert(st); + assert(st == SERD_ERR_BAD_ARG); + + serd_free(serd_buffer_sink_finish(&buffer)); + serd_writer_free(writer); + serd_byte_sink_free(byte_sink); + serd_env_free(env); + serd_world_free(world); +} + int main(void) { @@ -295,6 +330,7 @@ main(void) test_strict_write(); test_write_error(); test_write_empty_syntax(); + test_write_bad_uri(); return 0; } -- cgit v1.2.1