aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/serd_test.c351
1 files changed, 193 insertions, 158 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c
index dfa3d397..cf039e1c 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -92,24 +92,25 @@ check_file_uri(const char* hostname,
expected_path = path;
}
- SerdNode node = serd_node_new_file_uri(path, hostname, 0, escape);
- char* out_hostname = NULL;
- char* out_path = serd_file_uri_parse(node.buf, &out_hostname);
- int ret = 0;
- if (strcmp((const char*)node.buf, expected_uri)) {
- ret = FAILF("Bad URI %s != %s\n", node.buf, expected_uri);
+ SerdNode* node = serd_node_new_file_uri(path, hostname, 0, escape);
+ const char* node_str = serd_node_get_string(node);
+ char* out_hostname = NULL;
+ char* out_path = serd_file_uri_parse(node_str, &out_hostname);
+ int ret = 0;
+ if (strcmp(node_str, expected_uri)) {
+ ret = FAILF("Bad URI %s != %s\n", node_str, expected_uri);
} else if (!hostname && out_hostname) {
ret = FAILF("hostname `%s' shouldn't exist\n", out_hostname);
} else if (hostname && !out_hostname) {
ret = FAILF("expected hostname `%s'\n", hostname);
} else if (strcmp((const char*)out_path, (const char*)expected_path)) {
ret = FAILF("path=>URI=>path failure %s => %s => %s\n",
- path, node.buf, out_path);
+ path, node_str, out_path);
}
free(out_path);
free(out_hostname);
- serd_node_free(&node);
+ serd_node_free(node);
return ret;
}
@@ -155,20 +156,19 @@ main(void)
};
for (unsigned i = 0; i < sizeof(dbl_test_nums) / sizeof(double); ++i) {
- SerdNode node = serd_node_new_decimal(dbl_test_nums[i], 8);
- const bool pass = (node.buf && dbl_test_strs[i])
- ? !strcmp(node.buf, dbl_test_strs[i])
- : (node.buf == dbl_test_strs[i]);
+ SerdNode* node = serd_node_new_decimal(dbl_test_nums[i], 8);
+ const char* node_str = serd_node_get_string(node);
+ const bool pass = (node_str && dbl_test_strs[i])
+ ? !strcmp(node_str, dbl_test_strs[i])
+ : (node_str == dbl_test_strs[i]);
if (!pass) {
- FAILF("Serialised `%s' != %s\n",
- node.buf, dbl_test_strs[i]);
+ FAILF("Serialised `%s' != %s\n", node_str, dbl_test_strs[i]);
}
- const size_t len = node.buf ? strlen(node.buf) : 0;
- if (node.n_bytes != len) {
- FAILF("Length %zu != %zu\n",
- node.n_bytes, len);
+ const size_t len = node_str ? strlen(node_str) : 0;
+ if (serd_node_get_length(node) != len) {
+ FAILF("Length %zu != %zu\n", serd_node_get_length(node), len);
}
- serd_node_free(&node);
+ serd_node_free(node);
}
// Test serd_node_new_integer
@@ -182,17 +182,16 @@ main(void)
};
for (unsigned i = 0; i < sizeof(int_test_nums) / sizeof(double); ++i) {
- SerdNode node = serd_node_new_integer(int_test_nums[i]);
- if (strcmp((const char*)node.buf, (const char*)int_test_strs[i])) {
- FAILF("Serialised `%s' != %s\n",
- node.buf, int_test_strs[i]);
+ SerdNode* node = serd_node_new_integer(int_test_nums[i]);
+ const char* node_str = serd_node_get_string(node);
+ if (strcmp(node_str, (const char*)int_test_strs[i])) {
+ FAILF("Serialised `%s' != %s\n", node_str, int_test_strs[i]);
}
- const size_t len = strlen(node.buf);
- if (node.n_bytes != len) {
- FAILF("Length %zu,%zu != %zu\n",
- node.n_bytes, len);
+ const size_t len = strlen(node_str);
+ if (serd_node_get_length(node) != len) {
+ FAILF("Length %zu,%zu != %zu\n", serd_node_get_length(node), len);
}
- serd_node_free(&node);
+ serd_node_free(node);
}
// Test serd_node_new_blob
@@ -202,10 +201,11 @@ main(void)
data[i] = (uint8_t)(rand() % 256);
}
- SerdNode blob = serd_node_new_blob(data, size, size % 5);
- size_t out_size;
- uint8_t* out = (uint8_t*)serd_base64_decode(
- blob.buf, blob.n_bytes, &out_size);
+ size_t out_size;
+ SerdNode* blob = serd_node_new_blob(data, size, size % 5);
+ const char* blob_str = serd_node_get_string(blob);
+ uint8_t* out = (uint8_t*)serd_base64_decode(
+ blob_str, serd_node_get_length(blob), &out_size);
if (out_size != size) {
FAILF("Blob size %zu != %zu\n", out_size, size);
}
@@ -216,7 +216,7 @@ main(void)
}
}
- serd_node_free(&blob);
+ serd_node_free(blob);
free(out);
free(data);
}
@@ -310,148 +310,167 @@ main(void)
// Test serd_node_equals
const uint8_t replacement_char_str[] = { 0xEF, 0xBF, 0xBD, 0 };
- SerdNode lhs = serd_node_from_string(SERD_LITERAL, (const char*)replacement_char_str);
- SerdNode rhs = serd_node_from_string(SERD_LITERAL, "123");
- if (serd_node_equals(&lhs, &rhs)) {
- FAILF("%s == %s\n", lhs.buf, rhs.buf);
+ SerdNode* lhs = serd_node_new_string(SERD_LITERAL, (const char*)replacement_char_str);
+ SerdNode* rhs = serd_node_new_string(SERD_LITERAL, "123");
+ if (serd_node_equals(lhs, rhs)) {
+ FAILF("%s == %s\n",
+ serd_node_get_string(lhs), serd_node_get_string(rhs));
}
- SerdNode qnode = serd_node_from_string(SERD_CURIE, "foo:bar");
- if (serd_node_equals(&lhs, &qnode)) {
- FAILF("%s == %s\n", lhs.buf, qnode.buf);
+ SerdNode* qnode = serd_node_new_string(SERD_CURIE, "foo:bar");
+ if (serd_node_equals(lhs, qnode)) {
+ FAILF("%s == %s\n",
+ serd_node_get_string(lhs), serd_node_get_string(qnode));
}
+ serd_node_free(qnode);
- if (!serd_node_equals(&lhs, &lhs)) {
- FAILF("%s != %s\n", lhs.buf, lhs.buf);
+ if (!serd_node_equals(lhs, lhs)) {
+ FAILF("%s != %s\n",
+ serd_node_get_string(lhs), serd_node_get_string(lhs));
}
- SerdNode null_copy = serd_node_copy(&SERD_NODE_NULL);
- if (!serd_node_equals(&SERD_NODE_NULL, &null_copy)) {
- FAIL("copy of null node != null node\n");
+ if (serd_node_copy(NULL)) {
+ FAIL("made non-null copy of null node\n");
}
- // Test serd_node_from_string
+ serd_node_free(lhs);
+ serd_node_free(rhs);
- SerdNode node = serd_node_from_string(SERD_LITERAL, "hello\"");
- if (node.n_bytes != 6 || node.flags != SERD_HAS_QUOTE
- || strcmp((const char*)node.buf, "hello\"")) {
- FAILF("Bad node %s %zu %d %d\n",
- node.buf, node.n_bytes, node.flags, node.type);
+ // Test serd_node_new_string
+
+ SerdNode* hello = serd_node_new_string(SERD_LITERAL, "hello\"");
+ if (serd_node_get_length(hello) != 6 ||
+ serd_node_get_flags(hello) != SERD_HAS_QUOTE ||
+ strcmp(serd_node_get_string(hello), "hello\"")) {
+ FAILF("Bad node %s\n", serd_node_get_string(hello));
}
- node = serd_node_from_string(SERD_URI, NULL);
- if (!serd_node_equals(&node, &SERD_NODE_NULL)) {
- FAIL("Creating node from NULL string failed\n");
+ if (serd_node_new_string(SERD_URI, NULL)) {
+ FAIL("Successfully created node from NULL string\n");
}
- // Test serd_node_from_substring
+ // Test serd_node_new_substring
- SerdNode empty = serd_node_from_substring(SERD_LITERAL, NULL, 32);
- if (empty.buf || empty.n_bytes || empty.flags || empty.type) {
+ if (serd_node_new_substring(SERD_LITERAL, NULL, 32)) {
FAIL("Successfully created node from NULL substring\n");
}
- SerdNode a_b = serd_node_from_substring(SERD_LITERAL, "a\"bc", 3);
- if (a_b.n_bytes != 3 || a_b.flags != SERD_HAS_QUOTE
- || strncmp((const char*)a_b.buf, "a\"b", 3)) {
- FAILF("Bad node %s %zu %d %d\n",
- a_b.buf, a_b.n_bytes, a_b.flags, a_b.type);
+ SerdNode* a_b = serd_node_new_substring(SERD_LITERAL, "a\"bc", 3);
+ if (serd_node_get_length(a_b) != 3 ||
+ serd_node_get_flags(a_b) != SERD_HAS_QUOTE ||
+ strncmp(serd_node_get_string(a_b), "a\"b", 3)) {
+ FAILF("Bad node %s\n", serd_node_get_string(a_b));
}
- a_b = serd_node_from_substring(SERD_LITERAL, "a\"bc", 10);
- if (a_b.n_bytes != 4 || a_b.flags != SERD_HAS_QUOTE
- || strncmp((const char*)a_b.buf, "a\"bc", 4)) {
- FAILF("Bad node %s %zu %zu %d %d\n",
- a_b.buf, a_b.n_bytes, a_b.flags, a_b.type);
+ serd_node_free(a_b);
+ a_b = serd_node_new_substring(SERD_LITERAL, "a\"bc", 10);
+ if (serd_node_get_length(a_b) != 4 ||
+ serd_node_get_flags(a_b) != SERD_HAS_QUOTE ||
+ strncmp(serd_node_get_string(a_b), "a\"bc", 4)) {
+ FAILF("Bad node %s\n", serd_node_get_string(a_b));
}
+ serd_node_free(a_b);
// Test serd_node_new_uri_from_string
- SerdNode nonsense = serd_node_new_uri_from_string(NULL, NULL, NULL);
- if (nonsense.type != SERD_NOTHING) {
+ if (serd_node_new_uri_from_string(NULL, NULL, NULL)) {
FAIL("Successfully created NULL URI\n");
}
SerdURI base_uri;
- SerdNode base = serd_node_new_uri_from_string("http://example.org/",
+ SerdNode* base = serd_node_new_uri_from_string("http://example.org/",
NULL, &base_uri);
- SerdNode nil = serd_node_new_uri_from_string(NULL, &base_uri, NULL);
- SerdNode nil2 = serd_node_new_uri_from_string("", &base_uri, NULL);
- if (nil.type != SERD_URI || strcmp((const char*)nil.buf, (const char*)base.buf) ||
- nil2.type != SERD_URI || strcmp((const char*)nil2.buf, (const char*)base.buf)) {
- FAILF("URI %s != base %s\n", nil.buf, base.buf);
+ SerdNode* nil = serd_node_new_uri_from_string(NULL, &base_uri, NULL);
+ SerdNode* nil2 = serd_node_new_uri_from_string("", &base_uri, NULL);
+ if (serd_node_get_type(nil) != SERD_URI ||
+ strcmp(serd_node_get_string(nil), serd_node_get_string(base)) ||
+ serd_node_get_type(nil2) != SERD_URI ||
+ strcmp(serd_node_get_string(nil2), serd_node_get_string(base))) {
+ FAILF("URI %s != base %s\n",
+ serd_node_get_string(nil),
+ serd_node_get_string(base));
}
- serd_node_free(&nil);
- serd_node_free(&nil2);
// Test serd_node_new_relative_uri
- SerdNode abs = serd_node_from_string(SERD_URI, "http://example.org/foo/bar");
- SerdURI abs_uri;
- serd_uri_parse(abs.buf, &abs_uri);
+ SerdNode* abs = serd_node_new_string(SERD_URI, "http://example.org/foo/bar");
+ SerdURI abs_uri;
+ serd_uri_parse(serd_node_get_string(abs), &abs_uri);
- SerdURI rel_uri;
- SerdNode rel = serd_node_new_relative_uri(&abs_uri, &base_uri, NULL, &rel_uri);
- if (strcmp((const char*)rel.buf, "/foo/bar")) {
- FAILF("Bad relative URI %s (expected '/foo/bar')\n", rel.buf);
+ SerdURI rel_uri;
+ SerdNode* rel = serd_node_new_relative_uri(&abs_uri, &base_uri, NULL, &rel_uri);
+ if (strcmp(serd_node_get_string(rel), "/foo/bar")) {
+ FAILF("Bad relative URI %s (expected '/foo/bar')\n",
+ serd_node_get_string(rel));
}
- serd_node_free(&rel);
- serd_node_free(&base);
+ serd_node_free(abs);
+ serd_node_free(nil);
+ serd_node_free(nil2);
+ serd_node_free(rel);
+ serd_node_free(base);
// Test SerdEnv
- SerdNode u = serd_node_from_string(SERD_URI, "http://example.org/foo");
- SerdNode b = serd_node_from_string(SERD_CURIE, "invalid");
- SerdNode c = serd_node_from_string(SERD_CURIE, "eg.2:b");
- SerdEnv* env = serd_env_new(NULL);
+ SerdNode* u = serd_node_new_string(SERD_URI, "http://example.org/foo");
+ SerdNode* b = serd_node_new_string(SERD_CURIE, "invalid");
+ SerdNode* c = serd_node_new_string(SERD_CURIE, "eg.2:b");
+ SerdEnv* env = serd_env_new(NULL);
serd_env_set_prefix_from_strings(env, "eg.2", "http://example.org/");
+ if (serd_env_get_base_uri(env, NULL)) {
+ FAIL("Unexpected initial base URI\n");
+ }
+
if (!serd_env_set_base_uri(env, NULL)) {
FAIL("Successfully set NULL base URI\n");
}
- if (!serd_env_set_base_uri(env, &node)) {
- FAILF("Set base URI to %s\n", node.buf);
+ if (!serd_env_set_base_uri(env, hello)) {
+ FAILF("Set base URI to %s\n", serd_node_get_string(hello));
}
- if (!serd_node_equals(serd_env_get_base_uri(env, NULL), &node)) {
- FAIL("Base URI mismatch\n");
+ if (serd_env_get_base_uri(env, NULL)) {
+ FAIL("Unexpected base URI\n");
}
SerdSlice prefix, suffix;
- if (!serd_env_expand(env, &b, &prefix, &suffix)) {
- FAILF("Expanded invalid curie %s\n", b.buf);
+ if (!serd_env_expand(env, b, &prefix, &suffix)) {
+ FAILF("Expanded invalid curie %s\n", serd_node_get_string(b));
}
- SerdNode xnode = serd_env_expand_node(env, &node);
- if (!serd_node_equals(&xnode, &SERD_NODE_NULL)) {
- FAILF("Expanded %s to %s\n", c.buf, xnode.buf);
+ SerdNode* xnode = serd_env_expand_node(env, hello);
+ if (xnode) {
+ FAILF("Expanded %s\n", serd_node_get_string(c));
}
+ serd_node_free(hello);
- SerdNode xu = serd_env_expand_node(env, &u);
- if (strcmp((const char*)xu.buf, "http://example.org/foo")) {
- FAILF("Expanded %s to %s\n", c.buf, xu.buf);
+ SerdNode* xu = serd_env_expand_node(env, u);
+ if (strcmp(serd_node_get_string(xu), "http://example.org/foo")) {
+ FAILF("Expanded %s to %s\n",
+ serd_node_get_string(c), serd_node_get_string(xu));
}
- serd_node_free(&xu);
+ serd_node_free(xu);
- SerdNode badpre = serd_node_from_string(SERD_CURIE, "hm:what");
- SerdNode xbadpre = serd_env_expand_node(env, &badpre);
- if (!serd_node_equals(&xbadpre, &SERD_NODE_NULL)) {
- FAILF("Expanded invalid curie %s\n", badpre.buf);
+ SerdNode* badpre = serd_node_new_string(SERD_CURIE, "hm:what");
+ SerdNode* xbadpre = serd_env_expand_node(env, badpre);
+ if (xbadpre) {
+ FAILF("Expanded invalid curie %s\n", serd_node_get_string(badpre));
}
+ serd_node_free(badpre);
- SerdNode xc = serd_env_expand_node(env, &c);
- if (strcmp((const char*)xc.buf, "http://example.org/b")) {
- FAILF("Expanded %s to %s\n", c.buf, xc.buf);
+ SerdNode* xc = serd_env_expand_node(env, c);
+ if (strcmp(serd_node_get_string(xc), "http://example.org/b")) {
+ FAILF("Expanded %s to %s\n",
+ serd_node_get_string(c), serd_node_get_string(xc));
}
- serd_node_free(&xc);
+ serd_node_free(xc);
- if (!serd_env_set_prefix(env, &SERD_NODE_NULL, &SERD_NODE_NULL)) {
+ if (!serd_env_set_prefix(env, NULL, NULL)) {
FAIL("Set NULL prefix\n");
}
- const SerdNode lit = serd_node_from_string(SERD_LITERAL, "hello");
- if (!serd_env_set_prefix(env, &b, &lit)) {
+ SerdNode* lit = serd_node_new_string(SERD_LITERAL, "hello");
+ if (!serd_env_set_prefix(env, b, lit)) {
FAIL("Set prefix to literal\n");
}
@@ -462,11 +481,15 @@ main(void)
FAILF("Bad prefix count %d\n", n_prefixes);
}
- SerdNode shorter_uri = serd_node_from_string(SERD_URI, "urn:foo");
- SerdNode prefix_name;
- if (serd_env_qualify(env, &shorter_uri, &prefix_name, &suffix)) {
- FAILF("Qualified %s\n", shorter_uri.buf);
+ SerdNode* shorter_uri = serd_node_new_string(SERD_URI, "urn:foo");
+ const SerdNode* prefix_name;
+ if (serd_env_qualify(env, shorter_uri, &prefix_name, &suffix)) {
+ FAILF("Qualified %s\n", serd_node_get_string(shorter_uri));
}
+ serd_node_free(shorter_uri);
+ serd_node_free(u);
+ serd_node_free(b);
+ serd_node_free(c);
// Test SerdReader and SerdWriter
@@ -485,10 +508,11 @@ main(void)
serd_writer_chop_blank_prefix(writer, "tmp");
serd_writer_chop_blank_prefix(writer, NULL);
- if (!serd_writer_set_base_uri(writer, &lit)) {
- FAILF("Set base URI to %s\n", lit.buf);
- } else if (!serd_writer_set_prefix(writer, &lit, &lit)) {
- FAILF("Set prefix %s to %s\n", lit.buf, lit.buf);
+ if (!serd_writer_set_base_uri(writer, lit)) {
+ FAILF("Set base URI to %s\n", serd_node_get_string(lit));
+ } else if (!serd_writer_set_prefix(writer, lit, lit)) {
+ FAILF("Set prefix %s to %s\n",
+ serd_node_get_string(lit), serd_node_get_string(lit));
} else if (!serd_writer_end_anon(writer, NULL)) {
FAIL("Ended non-existent anonymous node\n");
} else if (serd_writer_get_env(writer) != env) {
@@ -496,20 +520,20 @@ main(void)
}
uint8_t buf[] = { 0xEF, 0xBF, 0xBD, 0 };
- SerdNode s = serd_node_from_string(SERD_URI, "");
- SerdNode p = serd_node_from_string(SERD_URI, "http://example.org/pred");
- SerdNode o = serd_node_from_string(SERD_LITERAL, (char*)buf);
+ SerdNode* s = serd_node_new_string(SERD_URI, "");
+ SerdNode* p = serd_node_new_string(SERD_URI, "http://example.org/pred");
+ SerdNode* o = serd_node_new_string(SERD_LITERAL, (char*)buf);
// Write 3 invalid statements (should write nothing)
- const SerdNode* junk[][5] = { { &s, &p, NULL, NULL, NULL },
- { &s, NULL, &o, NULL, NULL },
- { NULL, &p, &o, NULL, NULL },
- { &s, &p, &SERD_NODE_NULL, NULL, NULL },
- { &s, &SERD_NODE_NULL, &o, NULL, NULL },
- { &SERD_NODE_NULL, &p, &o, NULL, NULL },
- { &s, &o, &o, NULL, NULL },
- { &o, &p, &o, NULL, NULL },
- { &s, &p, &SERD_NODE_NULL, NULL, NULL },
+ const SerdNode* junk[][5] = { { s, p, NULL, NULL, NULL },
+ { s, NULL, o, NULL, NULL },
+ { NULL, p, o, NULL, NULL },
+ { s, p, NULL, NULL, NULL },
+ { s, NULL, o, NULL, NULL },
+ { NULL, p, o, NULL, NULL },
+ { s, o, o, NULL, NULL },
+ { o, p, o, NULL, NULL },
+ { s, p, NULL, NULL, NULL },
{ NULL, NULL, NULL, NULL, NULL } };
for (unsigned i = 0; i < sizeof(junk) / (sizeof(SerdNode*) * 5); ++i) {
if (!serd_writer_write_statement(
@@ -519,18 +543,18 @@ main(void)
}
}
- const SerdNode t = serd_node_from_string(SERD_URI, "urn:Type");
- const SerdNode l = serd_node_from_string(SERD_LITERAL, "en");
- const SerdNode* good[][5] = { { &s, &p, &o, NULL, NULL },
- { &s, &p, &o, &SERD_NODE_NULL, &SERD_NODE_NULL },
- { &s, &p, &o, &t, NULL },
- { &s, &p, &o, NULL, &l },
- { &s, &p, &o, &t, &l },
- { &s, &p, &o, &t, &SERD_NODE_NULL },
- { &s, &p, &o, &SERD_NODE_NULL, &l },
- { &s, &p, &o, NULL, &SERD_NODE_NULL },
- { &s, &p, &o, &SERD_NODE_NULL, NULL },
- { &s, &p, &o, &SERD_NODE_NULL, NULL } };
+ SerdNode* t = serd_node_new_string(SERD_URI, "urn:Type");
+ SerdNode* l = serd_node_new_string(SERD_LITERAL, "en");
+ const SerdNode* good[][5] = { { s, p, o, NULL, NULL },
+ { s, p, o, NULL, NULL },
+ { s, p, o, t, NULL },
+ { s, p, o, NULL, l },
+ { s, p, o, t, l },
+ { s, p, o, t, NULL },
+ { s, p, o, NULL, l },
+ { s, p, o, NULL, NULL },
+ { s, p, o, NULL, NULL },
+ { s, p, o, NULL, NULL } };
for (unsigned i = 0; i < sizeof(good) / (sizeof(SerdNode*) * 5); ++i) {
if (serd_writer_write_statement(
writer, 0, NULL,
@@ -541,35 +565,45 @@ main(void)
// Write statements with bad UTF-8 (should be replaced)
const char bad_str[] = { (char)0xFF, (char)0x90, 'h', 'i', 0 };
- SerdNode bad_lit = serd_node_from_string(SERD_LITERAL, bad_str);
- SerdNode bad_uri = serd_node_from_string(SERD_URI, bad_str);
+ SerdNode* bad_lit = serd_node_new_string(SERD_LITERAL, bad_str);
+ SerdNode* bad_uri = serd_node_new_string(SERD_URI, bad_str);
if (serd_writer_write_statement(writer, 0, NULL,
- &s, &p, &bad_lit, NULL, NULL)) {
+ s, p, bad_lit, NULL, NULL)) {
FAIL("Failed to write junk UTF-8 literal\n");
} else if (serd_writer_write_statement(writer, 0, NULL,
- &s, &p, &bad_uri, NULL, NULL)) {
+ s, p, bad_uri, NULL, NULL)) {
FAIL("Failed to write junk UTF-8 URI\n");
}
+ serd_node_free(bad_uri);
+ serd_node_free(bad_lit);
// Write 1 valid statement
- o = serd_node_from_string(SERD_LITERAL, "hello");
+ serd_node_free(o);
+ o = serd_node_new_string(SERD_LITERAL, "hello");
if (serd_writer_write_statement(writer, 0, NULL,
- &s, &p, &o, NULL, NULL)) {
+ s, p, o, NULL, NULL)) {
FAIL("Failed to write valid statement\n");
}
serd_writer_free(writer);
+ serd_node_free(lit);
+ serd_node_free(s);
+ serd_node_free(p);
+ serd_node_free(o);
+ serd_node_free(t);
+ serd_node_free(l);
// Test buffer sink
SerdBuffer buffer = { NULL, 0 };
writer = serd_writer_new(
SERD_TURTLE, (SerdStyle)0, env, NULL, serd_buffer_sink, &buffer);
- o = serd_node_from_string(SERD_URI, "http://example.org/base");
- if (serd_writer_set_base_uri(writer, &o)) {
+ o = serd_node_new_string(SERD_URI, "http://example.org/base");
+ if (serd_writer_set_base_uri(writer, o)) {
FAIL("Failed to write to chunk sink\n");
}
+ serd_node_free(o);
serd_writer_free(writer);
char* out = serd_buffer_sink_finish(&buffer);
@@ -593,10 +627,11 @@ main(void)
FAIL("Corrupt reader handle\n");
}
- SerdNode g = serd_node_from_string(SERD_URI, "http://example.org/");
- serd_reader_set_default_graph(reader, &g);
+ SerdNode* g = serd_node_new_string(SERD_URI, "http://example.org/");
+ serd_reader_set_default_graph(reader, g);
serd_reader_add_blank_prefix(reader, "tmp");
serd_reader_add_blank_prefix(reader, NULL);
+ serd_node_free(g);
if (!serd_reader_read_file(reader, "http://notafile")) {
FAIL("Apparently read an http URI\n");
@@ -611,8 +646,8 @@ main(void)
FAILF("Error reading file (%s)\n", serd_strerror(st));
} else if (rt->n_statements != 13) {
FAILF("Bad statement count %d\n", rt->n_statements);
- } else if (!rt->graph || !rt->graph->buf ||
- strcmp((const char*)rt->graph->buf, "http://example.org/")) {
+ } else if (!rt->graph || !serd_node_get_string(rt->graph) ||
+ strcmp(serd_node_get_string(rt->graph), "http://example.org/")) {
FAILF("Bad graph %p\n", rt->graph);
}