aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_overflow.c44
-rw-r--r--test/test_string.c2
-rw-r--r--test/test_writer.c36
3 files changed, 75 insertions, 7 deletions
diff --git a/test/test_overflow.c b/test/test_overflow.c
index 7f08112d..02b71008 100644
--- a/test/test_overflow.c
+++ b/test/test_overflow.c
@@ -21,7 +21,7 @@
#include <assert.h>
#include <stdio.h>
-static const size_t min_stack_size = 4 * sizeof(size_t) + 256u;
+static const size_t min_stack_size = 4 * sizeof(size_t) + 230u;
static const size_t max_stack_size = 1024u;
static SerdStatus
@@ -90,11 +90,9 @@ static void
test_turtle_overflow(void)
{
static const char* const test_strings[] = {
- "<http://example.org/s> <http://example.org/p> :%99 .",
"<http://example.org/s> <http://example.org/p> <http://example.org/> .",
"<http://example.org/s> <http://example.org/p> "
"<thisisanabsurdlylongurischeme://because/testing/> .",
- "<http://example.org/s> <http://example.org/p> eg:foo .",
"<http://example.org/s> <http://example.org/p> 1234 .",
"<http://example.org/s> <http://example.org/p> (1 2 3 4) .",
"<http://example.org/s> <http://example.org/p> (((((((42))))))) .",
@@ -112,7 +110,41 @@ test_turtle_overflow(void)
"@prefix ug.dot: <http://example.org/> . \nug.dot:s ug.dot:p ug.dot:o .\n",
// NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
- "@prefix øøøøøøøøø: <http://example.org/long> . \n"
+ "<http://example.org/subject/with/a/long/path> "
+ "<http://example.org/predicate/with/a/long/path> "
+ "<http://example.org/object/with/a/long/path> .",
+
+ // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
+ "<http://example.org/s> <http://example.org/p> "
+ "\"typed\"^^<http://example.org/Datatype> .",
+
+ // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
+ "@prefix eg: <http://example.org/ns/test> .\n"
+ "<http://example.org/s> <http://example.org/p> "
+ "\"typed\"^^eg:Datatype .",
+
+ // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
+ "@prefix eg: <http://example.org/ns/test> .\n"
+ "<http://example.org/s> <http://example.org/p> eg:foo .",
+
+ // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
+ "@prefix prefix: <http://example.org/testing/curies> .\n"
+ "prefix:subject prefix:predicate prefix:object .\n",
+
+ // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
+ "@prefix eg: <http://example.org/> .\n"
+ "eg:s eg:p [ eg:p [ eg:p [ eg:p [ eg:p []]]]] .\n",
+
+ // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
+ "@prefix eg: <http://example.org/> .\n"
+ "eg:s eg:p ( 1 2 3 ( 4 5 6 ( 7 8 9 ) ) ) .\n",
+
+ // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
+ "@prefix eg: <http://example.org/ns/test> .\n"
+ "<http://example.org/s> <http://example.org/p> eg:%99 .",
+
+ // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
+ "@prefix øøøøøøøøø: <http://example.org/long> .\n"
"<http://example.org/somewhatlongsubjecttooffsetthepredicate> øøøøøøøøø:p "
"øøøøøøøøø:o .\n",
@@ -140,8 +172,8 @@ test_turtle_overflow(void)
// NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
"@prefix prefix: <http://example.org/testing/curies> .\n"
- "prefix:subjectthatwillcomearoundtobeingfinishedanycharacternow "
- "prefix:predicate prefix:object .\n",
+ "<http://example.org/very/long/uri/subject/to/overflow/the/predicate> "
+ "prefix:predicate prefix:object ; prefix:p prefix:o .\n",
// NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
"@prefix eg: <http://example.org/> .\n"
diff --git a/test/test_string.c b/test/test_string.c
index 495138d8..2f805015 100644
--- a/test/test_string.c
+++ b/test/test_string.c
@@ -44,7 +44,7 @@ test_strerror(void)
{
const char* msg = serd_strerror(SERD_SUCCESS);
assert(!strcmp(msg, "Success"));
- for (int i = SERD_FAILURE; i <= SERD_ERR_BAD_CALL; ++i) {
+ for (int i = SERD_FAILURE; i <= SERD_ERR_BAD_URI; ++i) {
msg = serd_strerror((SerdStatus)i);
assert(strcmp(msg, "Success"));
}
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;
}