aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/meson.build1
-rw-r--r--test/test_cursor.c59
-rw-r--r--test/test_free_null.c1
-rw-r--r--test/test_read_chunk.c3
-rw-r--r--test/test_reader_writer.c3
5 files changed, 65 insertions, 2 deletions
diff --git a/test/meson.build b/test/meson.build
index e45af26c..82a307d2 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -3,6 +3,7 @@ run_test_suite = find_program('run_test_suite.py')
wrapper = meson.get_cross_property('wrapper', '')
unit_tests = [
+ 'cursor',
'env',
'free_null',
'node',
diff --git a/test/test_cursor.c b/test/test_cursor.c
new file mode 100644
index 00000000..3a8ca975
--- /dev/null
+++ b/test/test_cursor.c
@@ -0,0 +1,59 @@
+/*
+ Copyright 2019-2020 David Robillard <d@drobilla.net>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+#undef NDEBUG
+
+#include "serd/serd.h"
+
+#include <assert.h>
+#include <stddef.h>
+
+int
+main(void)
+{
+ SerdNode* const node = serd_new_string(SERD_STATIC_STRING("node"));
+ SerdCursor* const cursor = serd_cursor_new(node, 46, 2);
+
+ assert(serd_cursor_name(cursor) == node);
+ assert(serd_cursor_line(cursor) == 46);
+ assert(serd_cursor_column(cursor) == 2);
+
+ SerdCursor* const copy = serd_cursor_copy(cursor);
+
+ assert(serd_cursor_equals(cursor, copy));
+ assert(!serd_cursor_copy(NULL));
+
+ SerdNode* const other_node = serd_new_string(SERD_STATIC_STRING("other"));
+ SerdCursor* const other_file = serd_cursor_new(other_node, 46, 2);
+ SerdCursor* const other_line = serd_cursor_new(node, 47, 2);
+ SerdCursor* const other_col = serd_cursor_new(node, 46, 3);
+
+ assert(!serd_cursor_equals(cursor, other_file));
+ assert(!serd_cursor_equals(cursor, other_line));
+ assert(!serd_cursor_equals(cursor, other_col));
+ assert(!serd_cursor_equals(cursor, NULL));
+ assert(!serd_cursor_equals(NULL, cursor));
+
+ serd_cursor_free(other_col);
+ serd_cursor_free(other_line);
+ serd_cursor_free(other_file);
+ serd_node_free(other_node);
+ serd_cursor_free(copy);
+ serd_cursor_free(cursor);
+ serd_node_free(node);
+
+ return 0;
+}
diff --git a/test/test_free_null.c b/test/test_free_null.c
index 3977507c..05be8e4a 100644
--- a/test/test_free_null.c
+++ b/test/test_free_null.c
@@ -30,6 +30,7 @@ main(void)
serd_sink_free(NULL);
serd_reader_free(NULL);
serd_writer_free(NULL);
+ serd_cursor_free(NULL);
return 0;
}
diff --git a/test/test_read_chunk.c b/test/test_read_chunk.c
index e15d3c50..8be4ad63 100644
--- a/test/test_read_chunk.c
+++ b/test/test_read_chunk.c
@@ -98,7 +98,8 @@ main(void)
"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"));
+ "eg:s4 eg:p1 [ eg:p3 eg:o1 ] .\n",
+ NULL));
assert(!serd_reader_read_chunk(reader) && n_prefix == 1);
assert(!serd_reader_read_chunk(reader) && n_base == 1);
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index 8742289a..788b2d63 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -168,7 +168,8 @@ test_read_string(void)
assert(
!serd_reader_start_string(reader,
"<http://example.org/s> <http://example.org/p> "
- "<http://example.org/o> ."));
+ "<http://example.org/o> .",
+ NULL));
assert(!serd_reader_read_document(reader));
assert(n_statements == 1);