diff options
author | David Robillard <d@drobilla.net> | 2021-04-15 17:52:44 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:08 -0500 |
commit | 8c67f9eba47d30913749e607c440b170a5cbd804 (patch) | |
tree | 01d9750c6e646c76519e3a00bb200d6312e65ffc /test/test_writer.c | |
parent | 7ffa2c0488fcd96c3c12713e5650633eb03e91f7 (diff) | |
download | serd-8c67f9eba47d30913749e607c440b170a5cbd804.tar.gz serd-8c67f9eba47d30913749e607c440b170a5cbd804.tar.bz2 serd-8c67f9eba47d30913749e607c440b170a5cbd804.zip |
[WIP] 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.
Diffstat (limited to 'test/test_writer.c')
-rw-r--r-- | test/test_writer.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/test_writer.c b/test/test_writer.c index f76cc800..ee602044 100644 --- a/test/test_writer.c +++ b/test/test_writer.c @@ -406,6 +406,36 @@ test_write_pname_escapes(void) check_pname_escape((const char*)last_escape, "eg:s\n\teg:p eg:wx%C3%B7 .\n"); } +static void +test_write_bad_uri(void) +{ + SerdWorld* world = serd_world_new(); + SerdEnv* env = serd_env_new(serd_empty_string()); + SerdNode* s = serd_new_uri(serd_string("http://example.org/s")); + SerdNode* p = serd_new_uri(serd_string("http://example.org/p")); + SerdNode* rel = serd_new_uri(serd_string("rel")); + SerdBuffer buffer = {NULL, 0}; + SerdOutputStream output = serd_open_output_buffer(&buffer); + SerdWriter* writer = + serd_writer_new(world, SERD_NTRIPLES, 0U, env, &output, 1); + + assert(writer); + + const SerdStatus st = + serd_sink_write(serd_writer_sink(writer), 0U, s, p, rel, NULL); + assert(st); + assert(st == SERD_BAD_ARG); + + serd_writer_free(writer); + serd_close_output(&output); + serd_free(buffer.buf); + serd_node_free(rel); + serd_node_free(p); + serd_node_free(s); + serd_env_free(env); + serd_world_free(world); +} + int main(void) { @@ -418,6 +448,7 @@ main(void) test_writer_stack_overflow(); test_write_empty_syntax(); test_write_pname_escapes(); + test_write_bad_uri(); return 0; } |