aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/meson.build1
-rw-r--r--test/test_caret.c49
-rw-r--r--test/test_free_null.c2
-rw-r--r--test/test_overflow.c2
-rw-r--r--test/test_reader_writer.c5
5 files changed, 56 insertions, 3 deletions
diff --git a/test/meson.build b/test/meson.build
index efcb00f0..c3f29637 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -119,6 +119,7 @@ subdir('headers')
##############
unit_tests = [
+ 'caret',
'env',
'free_null',
'node',
diff --git a/test/test_caret.c b/test/test_caret.c
new file mode 100644
index 00000000..a239c242
--- /dev/null
+++ b/test/test_caret.c
@@ -0,0 +1,49 @@
+// Copyright 2019-2020 David Robillard <d@drobilla.net>
+// SPDX-License-Identifier: ISC
+
+#undef NDEBUG
+
+#include "serd/caret.h"
+#include "serd/node.h"
+#include "serd/string_view.h"
+
+#include <assert.h>
+#include <stddef.h>
+
+int
+main(void)
+{
+ SerdNode* const node = serd_new_string(serd_string("node"));
+ SerdCaret* const caret = serd_caret_new(node, 46, 2);
+
+ assert(serd_caret_equals(caret, caret));
+ assert(serd_caret_document(caret) == node);
+ assert(serd_caret_line(caret) == 46);
+ assert(serd_caret_column(caret) == 2);
+
+ SerdCaret* const copy = serd_caret_copy(caret);
+
+ assert(serd_caret_equals(caret, copy));
+ assert(!serd_caret_copy(NULL));
+
+ SerdNode* const other_node = serd_new_string(serd_string("other"));
+ SerdCaret* const other_file = serd_caret_new(other_node, 46, 2);
+ SerdCaret* const other_line = serd_caret_new(node, 47, 2);
+ SerdCaret* const other_col = serd_caret_new(node, 46, 3);
+
+ assert(!serd_caret_equals(caret, other_file));
+ assert(!serd_caret_equals(caret, other_line));
+ assert(!serd_caret_equals(caret, other_col));
+ assert(!serd_caret_equals(caret, NULL));
+ assert(!serd_caret_equals(NULL, caret));
+
+ serd_caret_free(other_col);
+ serd_caret_free(other_line);
+ serd_caret_free(other_file);
+ serd_node_free(other_node);
+ serd_caret_free(copy);
+ serd_caret_free(caret);
+ serd_node_free(node);
+
+ return 0;
+}
diff --git a/test/test_free_null.c b/test/test_free_null.c
index 72783328..87dfa7db 100644
--- a/test/test_free_null.c
+++ b/test/test_free_null.c
@@ -3,6 +3,7 @@
#undef NDEBUG
+#include "serd/caret.h"
#include "serd/env.h"
#include "serd/memory.h"
#include "serd/node.h"
@@ -23,6 +24,7 @@ main(void)
serd_sink_free(NULL);
serd_reader_free(NULL);
serd_writer_free(NULL);
+ serd_caret_free(NULL);
return 0;
}
diff --git a/test/test_overflow.c b/test/test_overflow.c
index a304ae1c..f4c5a863 100644
--- a/test/test_overflow.c
+++ b/test/test_overflow.c
@@ -23,7 +23,7 @@ test_size(SerdWorld* const world,
return SERD_BAD_STACK;
}
- serd_reader_start_string(reader, str);
+ serd_reader_start_string(reader, str, NULL);
const SerdStatus st = serd_reader_read_document(reader);
serd_reader_free(reader);
serd_sink_free(sink);
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index 062f65fc..39bde443 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -370,7 +370,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(rt->n_base == 0);
@@ -433,7 +434,7 @@ test_write_errors(void)
const SerdSink* const sink = serd_writer_sink(writer);
SerdReader* const reader = serd_reader_new(world, SERD_TRIG, sink, 4096U);
- SerdStatus st = serd_reader_start_string(reader, doc_string);
+ SerdStatus st = serd_reader_start_string(reader, doc_string, NULL);
assert(!st);
st = serd_reader_read_document(reader);
assert(st == SERD_BAD_WRITE);