aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/meson.build9
-rwxr-xr-xtest/test_empty.py27
-rw-r--r--test/test_writer.c34
3 files changed, 70 insertions, 0 deletions
diff --git a/test/meson.build b/test/meson.build
index cd748c0c..9724f18e 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -138,6 +138,15 @@ if get_option('utils')
should_fail: true,
suite: ['serdi', 'input'])
+ # Output
+
+ test('empty', files('test_empty.py'),
+ args: script_args + [serd_ttl],
+ env: test_env,
+ suite: 'output')
+
+ # FIXME: Old base URI argument?
+
# IO errors
test('read_dir', serdi,
diff --git a/test/test_empty.py b/test/test_empty.py
new file mode 100755
index 00000000..a7978e6c
--- /dev/null
+++ b/test/test_empty.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+
+"""Test writing empty output."""
+
+import argparse
+import sys
+import shlex
+import subprocess
+import tempfile
+
+parser = argparse.ArgumentParser(description=__doc__)
+
+parser.add_argument("--serdi", default="./serdi", help="path to serdi")
+parser.add_argument("--wrapper", default="", help="executable wrapper")
+parser.add_argument("input", help="valid input file")
+
+args = parser.parse_args(sys.argv[1:])
+command = shlex.split(args.wrapper) + [args.serdi, "-o", "empty", args.input]
+
+with tempfile.TemporaryFile() as out:
+
+ proc = subprocess.run(command, check=False, stdout=out)
+
+ out.seek(0, 2) # Seek to end
+
+ assert proc.returncode == 0
+ assert out.tell() == 0
diff --git a/test/test_writer.c b/test/test_writer.c
index aa5694cd..e31119bf 100644
--- a/test/test_writer.c
+++ b/test/test_writer.c
@@ -269,6 +269,39 @@ test_write_error(void)
serd_world_free(world);
}
+static void
+test_write_empty_syntax(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* o = serd_nodes_curie(nodes, SERD_STRING("eg:o"));
+
+ SerdBuffer buffer = {NULL, 0};
+
+ SerdWriter* writer = serd_writer_new(
+ world, SERD_SYNTAX_EMPTY, 0u, env, serd_buffer_sink, &buffer);
+
+ assert(writer);
+
+ assert(!serd_sink_write(serd_writer_sink(writer), 0u, s, p, o, NULL));
+
+ char* out = serd_buffer_sink_finish(&buffer);
+
+ assert(strlen(out) == 0);
+ serd_free(out);
+
+ serd_writer_free(writer);
+ serd_env_free(env);
+ serd_world_free(world);
+}
+
int
main(void)
{
@@ -278,6 +311,7 @@ main(void)
test_writer_stack_overflow();
test_strict_write();
test_write_error();
+ test_write_empty_syntax();
return 0;
}