diff options
author | David Robillard <d@drobilla.net> | 2016-03-16 16:21:20 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 16:27:02 -0500 |
commit | 84bab08585dec858807a6130bd2d71f304b889f0 (patch) | |
tree | ea78338414095c2c871944a0135028e1399b12fe /test | |
parent | caa74939cba8b1cd357e553efca9bec5074b1c53 (diff) | |
download | serd-84bab08585dec858807a6130bd2d71f304b889f0.tar.gz serd-84bab08585dec858807a6130bd2d71f304b889f0.tar.bz2 serd-84bab08585dec858807a6130bd2d71f304b889f0.zip |
Use char* for strings in public API
The constant casting just makes user code a mess, for no benefit.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_env.c | 27 | ||||
-rw-r--r-- | test/test_node.c | 35 | ||||
-rw-r--r-- | test/test_reader_writer.c | 60 | ||||
-rw-r--r-- | test/test_string.c | 12 | ||||
-rw-r--r-- | test/test_uri.c | 71 | ||||
-rw-r--r-- | test/test_writer.c | 29 |
6 files changed, 108 insertions, 126 deletions
diff --git a/test/test_env.c b/test/test_env.c index 1de075f3..b084de3b 100644 --- a/test/test_env.c +++ b/test/test_env.c @@ -6,11 +6,8 @@ #include "serd/serd.h" #include <assert.h> -#include <stdint.h> #include <string.h> -#define USTR(s) ((const uint8_t*)(s)) - static SerdStatus count_prefixes(void* handle, const SerdNode* name, const SerdNode* uri) { @@ -24,12 +21,11 @@ count_prefixes(void* handle, const SerdNode* name, const SerdNode* uri) static void test_env(void) { - SerdNode u = serd_node_from_string(SERD_URI, USTR("http://example.org/foo")); - SerdNode b = serd_node_from_string(SERD_CURIE, USTR("invalid")); - SerdNode c = serd_node_from_string(SERD_CURIE, USTR("eg.2:b")); + 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); - serd_env_set_prefix_from_strings( - env, USTR("eg.2"), USTR("http://example.org/")); + serd_env_set_prefix_from_strings(env, "eg.2", "http://example.org/"); assert(!serd_env_set_base_uri(env, NULL)); assert(serd_env_set_base_uri(env, &SERD_NODE_NULL)); @@ -48,35 +44,34 @@ test_env(void) assert(serd_node_equals(&xnode, &SERD_NODE_NULL)); SerdNode xu = serd_env_expand_node(env, &u); - assert(!strcmp((const char*)xu.buf, "http://example.org/foo")); + assert(!strcmp(xu.buf, "http://example.org/foo")); serd_node_free(&xu); - SerdNode badpre = serd_node_from_string(SERD_CURIE, USTR("hm:what")); + SerdNode badpre = serd_node_from_string(SERD_CURIE, "hm:what"); SerdNode xbadpre = serd_env_expand_node(env, &badpre); assert(serd_node_equals(&xbadpre, &SERD_NODE_NULL)); SerdNode xc = serd_env_expand_node(env, &c); - assert(!strcmp((const char*)xc.buf, "http://example.org/b")); + assert(!strcmp(xc.buf, "http://example.org/b")); serd_node_free(&xc); assert(serd_env_set_prefix(env, &SERD_NODE_NULL, &SERD_NODE_NULL)); - const SerdNode lit = serd_node_from_string(SERD_LITERAL, USTR("hello")); + const SerdNode lit = serd_node_from_string(SERD_LITERAL, "hello"); assert(serd_env_set_prefix(env, &b, &lit)); assert(!serd_env_new(&lit)); - const SerdNode blank = serd_node_from_string(SERD_BLANK, USTR("b1")); + const SerdNode blank = serd_node_from_string(SERD_BLANK, "b1"); const SerdNode xblank = serd_env_expand_node(env, &blank); assert(serd_node_equals(&xblank, &SERD_NODE_NULL)); int n_prefixes = 0; - serd_env_set_prefix_from_strings( - env, USTR("eg.2"), USTR("http://example.org/")); + serd_env_set_prefix_from_strings(env, "eg.2", "http://example.org/"); serd_env_foreach(env, count_prefixes, &n_prefixes); assert(n_prefixes == 1); - SerdNode shorter_uri = serd_node_from_string(SERD_URI, USTR("urn:foo")); + SerdNode shorter_uri = serd_node_from_string(SERD_URI, "urn:foo"); SerdNode prefix_name; assert(!serd_env_qualify(env, &shorter_uri, &prefix_name, &suffix)); diff --git a/test/test_node.c b/test/test_node.c index 1fc7f0bd..6343be5b 100644 --- a/test/test_node.c +++ b/test/test_node.c @@ -14,8 +14,6 @@ #include <stdlib.h> #include <string.h> -#define USTR(s) ((const uint8_t*)(s)) - #ifndef INFINITY # define INFINITY (DBL_MAX + DBL_MAX) #endif @@ -82,10 +80,10 @@ test_double_to_node(void) for (size_t 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((const char*)node.buf, dbl_test_strs[i]) - : ((const char*)node.buf == dbl_test_strs[i]); + ? !strcmp(node.buf, dbl_test_strs[i]) + : (node.buf == dbl_test_strs[i]); assert(pass); - const size_t len = node.buf ? strlen((const char*)node.buf) : 0; + const size_t len = node.buf ? strlen(node.buf) : 0; assert(node.n_bytes == len); serd_node_free(&node); } @@ -103,9 +101,8 @@ test_integer_to_node(void) for (size_t i = 0; i < N_TEST_NUMS; ++i) { SerdNode node = serd_node_new_integer(int_test_nums[i]); - assert(!strcmp((const char*)node.buf, (const char*)int_test_strs[i])); - const size_t len = strlen((const char*)node.buf); - assert(node.n_bytes == len); + assert(!strcmp(node.buf, int_test_strs[i])); + assert(node.n_bytes == strlen(node.buf)); serd_node_free(&node); } @@ -123,7 +120,7 @@ test_blob_to_node(void) SerdNode blob = serd_node_new_blob(data, size, size % 5); - assert(blob.n_bytes == strlen((const char*)blob.buf)); + assert(blob.n_bytes == strlen(blob.buf)); size_t out_size = 0; uint8_t* out = @@ -144,11 +141,12 @@ static void test_node_equals(void) { const uint8_t replacement_char_str[] = {0xEF, 0xBF, 0xBD, 0}; - SerdNode lhs = serd_node_from_string(SERD_LITERAL, replacement_char_str); - SerdNode rhs = serd_node_from_string(SERD_LITERAL, USTR("123")); + SerdNode lhs = + serd_node_from_string(SERD_LITERAL, (const char*)replacement_char_str); + SerdNode rhs = serd_node_from_string(SERD_LITERAL, "123"); assert(!serd_node_equals(&lhs, &rhs)); - SerdNode qnode = serd_node_from_string(SERD_CURIE, USTR("foo:bar")); + SerdNode qnode = serd_node_from_string(SERD_CURIE, "foo:bar"); assert(!serd_node_equals(&lhs, &qnode)); assert(serd_node_equals(&lhs, &lhs)); @@ -159,8 +157,9 @@ test_node_equals(void) static void test_node_from_string(void) { - SerdNode node = - serd_node_from_string(SERD_LITERAL, (const uint8_t*)"hello\""); + SerdNode node = serd_node_from_string(SERD_LITERAL, "hello\""); + assert(node.n_bytes == 6 && node.flags == SERD_HAS_QUOTE && + !strcmp(node.buf, "hello\"")); assert(node.n_bytes == 6 && node.flags == SERD_HAS_QUOTE && !strcmp((const char*)node.buf, "hello\"")); @@ -175,13 +174,13 @@ test_node_from_substring(void) SerdNode empty = serd_node_from_substring(SERD_LITERAL, NULL, 32); assert(!empty.buf && !empty.n_bytes && !empty.flags && !empty.type); - SerdNode a_b = serd_node_from_substring(SERD_LITERAL, USTR("a\"bc"), 3); + SerdNode a_b = serd_node_from_substring(SERD_LITERAL, "a\"bc", 3); assert(a_b.n_bytes == 3 && a_b.flags == SERD_HAS_QUOTE && - !strncmp((const char*)a_b.buf, "a\"b", 3)); + !strncmp(a_b.buf, "a\"b", 3)); - a_b = serd_node_from_substring(SERD_LITERAL, USTR("a\"bc"), 10); + a_b = serd_node_from_substring(SERD_LITERAL, "a\"bc", 10); assert(a_b.n_bytes == 4 && a_b.flags == SERD_HAS_QUOTE && - !strncmp((const char*)a_b.buf, "a\"bc", 4)); + !strncmp(a_b.buf, "a\"bc", 4)); } int diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c index cd7ca408..0555e7bb 100644 --- a/test/test_reader_writer.c +++ b/test/test_reader_writer.c @@ -17,8 +17,6 @@ #include <stdlib.h> #include <string.h> -#define USTR(s) ((const uint8_t*)(s)) - typedef struct { size_t n_written; size_t error_offset; @@ -353,10 +351,10 @@ test_read_string(void) assert(serd_reader_get_handle(reader) == rt); // Test reading a string that ends exactly at the end of input (no newline) - const SerdStatus st = serd_reader_read_string( - reader, - USTR("<http://example.org/s> <http://example.org/p> " - "<http://example.org/o> .")); + const SerdStatus st = + serd_reader_read_string(reader, + "<http://example.org/s> <http://example.org/p> " + "<http://example.org/o> ."); assert(!st); assert(rt->n_base == 0); @@ -424,7 +422,7 @@ test_write_errors(void) serd_reader_set_error_sink(reader, quiet_error_sink, NULL); serd_writer_set_error_sink(writer, quiet_error_sink, NULL); - const SerdStatus st = serd_reader_read_string(reader, USTR(doc_string)); + const SerdStatus st = serd_reader_read_string(reader, doc_string); assert(st == SERD_ERR_BAD_WRITE); serd_reader_free(reader); @@ -445,20 +443,20 @@ test_writer(const char* const path) serd_writer_new(SERD_TURTLE, (SerdStyle)0, env, NULL, serd_file_sink, fd); assert(writer); - serd_writer_chop_blank_prefix(writer, USTR("tmp")); + serd_writer_chop_blank_prefix(writer, "tmp"); serd_writer_chop_blank_prefix(writer, NULL); - const SerdNode lit = serd_node_from_string(SERD_LITERAL, USTR("hello")); + const SerdNode lit = serd_node_from_string(SERD_LITERAL, "hello"); assert(serd_writer_set_base_uri(writer, &lit)); assert(serd_writer_set_prefix(writer, &lit, &lit)); assert(serd_writer_end_anon(writer, NULL)); assert(serd_writer_get_env(writer) == env); - uint8_t buf[] = {0x80, 0, 0, 0, 0}; - SerdNode s = serd_node_from_string(SERD_URI, USTR("")); - SerdNode p = serd_node_from_string(SERD_URI, USTR("http://example.org/pred")); - SerdNode o = serd_node_from_string(SERD_LITERAL, buf); + 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); // Write 3 invalid statements (should write nothing) const SerdNode* junk[][5] = {{&s, &p, &SERD_NODE_NULL, NULL, NULL}, @@ -478,8 +476,8 @@ test_writer(const char* const path) junk[i][4])); } - const SerdNode t = serd_node_from_string(SERD_URI, USTR("urn:Type")); - const SerdNode l = serd_node_from_string(SERD_LITERAL, USTR("en")); + 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}, @@ -503,15 +501,15 @@ test_writer(const char* const path) // Write statements with bad UTF-8 (should be replaced) const uint8_t bad_str[] = {0xFF, 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_from_string(SERD_LITERAL, (const char*)bad_str); + SerdNode bad_uri = serd_node_from_string(SERD_URI, (const char*)bad_str); assert(!serd_writer_write_statement( writer, 0, NULL, &s, &p, &bad_lit, NULL, NULL)); assert(!serd_writer_write_statement( writer, 0, NULL, &s, &p, &bad_uri, NULL, NULL)); // Write 1 valid statement - o = serd_node_from_string(SERD_LITERAL, USTR("hello")); + o = serd_node_from_string(SERD_LITERAL, "hello"); assert(!serd_writer_write_statement(writer, 0, NULL, &s, &p, &o, NULL, NULL)); serd_writer_free(writer); @@ -521,17 +519,17 @@ test_writer(const char* const path) writer = serd_writer_new( SERD_TURTLE, (SerdStyle)0, env, NULL, serd_chunk_sink, &chunk); - o = serd_node_from_string(SERD_URI, USTR("http://example.org/base")); + o = serd_node_from_string(SERD_URI, "http://example.org/base"); assert(!serd_writer_set_base_uri(writer, &o)); serd_writer_free(writer); - uint8_t* out = serd_chunk_sink_finish(&chunk); + char* out = serd_chunk_sink_finish(&chunk); - assert(!strcmp((const char*)out, "@base <http://example.org/base> .\n")); + assert(!strcmp(out, "@base <http://example.org/base> .\n")); serd_free(out); // Test writing empty node - SerdNode nothing = serd_node_from_string(SERD_NOTHING, USTR("")); + SerdNode nothing = serd_node_from_string(SERD_NOTHING, ""); chunk.buf = NULL; chunk.len = 0; @@ -571,9 +569,9 @@ test_reader(const char* path) assert(serd_reader_read_chunk(reader) == SERD_FAILURE); - SerdNode g = serd_node_from_string(SERD_URI, USTR("http://example.org/")); + SerdNode g = serd_node_from_string(SERD_URI, "http://example.org/"); serd_reader_set_default_graph(reader, &g); - serd_reader_add_blank_prefix(reader, USTR("tmp")); + serd_reader_add_blank_prefix(reader, "tmp"); #if defined(__GNUC__) # pragma GCC diagnostic push @@ -584,25 +582,25 @@ test_reader(const char* path) # pragma GCC diagnostic pop #endif - assert(serd_reader_read_file(reader, USTR("http://notafile"))); - assert(serd_reader_read_file(reader, USTR("file:///better/not/exist"))); - assert(serd_reader_read_file(reader, USTR("file://"))); + assert(serd_reader_read_file(reader, "http://notafile")); + assert(serd_reader_read_file(reader, "file:///better/not/exist")); + assert(serd_reader_read_file(reader, "file://")); - const SerdStatus st = serd_reader_read_file(reader, USTR(path)); + const SerdStatus st = serd_reader_read_file(reader, path); assert(!st); assert(rt->n_base == 0); assert(rt->n_prefix == 0); assert(rt->n_statement == 13); assert(rt->n_end == 0); assert(rt->graph && rt->graph->buf && - !strcmp((const char*)rt->graph->buf, "http://example.org/")); + !strcmp(rt->graph->buf, "http://example.org/")); - assert(serd_reader_read_string(reader, USTR("This isn't Turtle at all."))); + assert(serd_reader_read_string(reader, "This isn't Turtle at all.")); // A read of a big page hits EOF then fails to read chunks immediately { FILE* const in = fopen(path, "rb"); - serd_reader_start_stream(reader, in, (const uint8_t*)"test", true); + serd_reader_start_stream(reader, in, "test", true); assert(serd_reader_read_chunk(reader) == SERD_SUCCESS); assert(serd_reader_read_chunk(reader) == SERD_FAILURE); diff --git a/test/test_string.c b/test/test_string.c index 85dccd62..99db03f4 100644 --- a/test/test_string.c +++ b/test/test_string.c @@ -16,23 +16,23 @@ test_strlen(void) const uint8_t str[] = {'"', '5', 0xE2, 0x82, 0xAC, '"', '\n', 0}; SerdNodeFlags flags = 0; - size_t n_bytes = serd_strlen(str, &flags); + size_t n_bytes = serd_strlen((const char*)str, &flags); assert(n_bytes == 7 && flags == (SERD_HAS_QUOTE | SERD_HAS_NEWLINE)); - assert(serd_strlen(str, NULL) == 7); + assert(serd_strlen((const char*)str, NULL) == 7); } static void test_strerror(void) { - const uint8_t* msg = serd_strerror(SERD_SUCCESS); - assert(!strcmp((const char*)msg, "Success")); + const char* msg = serd_strerror(SERD_SUCCESS); + assert(!strcmp(msg, "Success")); for (int i = SERD_FAILURE; i <= SERD_ERR_BAD_TEXT; ++i) { msg = serd_strerror((SerdStatus)i); - assert(strcmp((const char*)msg, "Success")); + assert(strcmp(msg, "Success")); } msg = serd_strerror((SerdStatus)-1); - assert(!strcmp((const char*)msg, "Unknown error")); + assert(!strcmp(msg, "Unknown error")); } int diff --git a/test/test_uri.c b/test/test_uri.c index 2747d008..d22ece63 100644 --- a/test/test_uri.c +++ b/test/test_uri.c @@ -7,31 +7,28 @@ #include <assert.h> #include <stdbool.h> -#include <stdint.h> #include <stdio.h> #include <string.h> -#define USTR(s) ((const uint8_t*)(s)) - static void test_uri_string_has_scheme(void) { - assert(!serd_uri_string_has_scheme(USTR("relative"))); - assert(!serd_uri_string_has_scheme(USTR("http"))); - assert(!serd_uri_string_has_scheme(USTR("5nostartdigit"))); - assert(!serd_uri_string_has_scheme(USTR("+nostartplus"))); - assert(!serd_uri_string_has_scheme(USTR("-nostartminus"))); - assert(!serd_uri_string_has_scheme(USTR(".nostartdot"))); - assert(!serd_uri_string_has_scheme(USTR(":missing"))); - assert(!serd_uri_string_has_scheme(USTR("a/slash/is/not/a/scheme/char"))); - - assert(serd_uri_string_has_scheme(USTR("http://example.org/"))); - assert(serd_uri_string_has_scheme(USTR("https://example.org/"))); - assert(serd_uri_string_has_scheme(USTR("allapha:path"))); - assert(serd_uri_string_has_scheme(USTR("w1thd1g1t5:path"))); - assert(serd_uri_string_has_scheme(USTR("with.dot:path"))); - assert(serd_uri_string_has_scheme(USTR("with+plus:path"))); - assert(serd_uri_string_has_scheme(USTR("with-minus:path"))); + assert(!serd_uri_string_has_scheme("relative")); + assert(!serd_uri_string_has_scheme("http")); + assert(!serd_uri_string_has_scheme("5nostartdigit")); + assert(!serd_uri_string_has_scheme("+nostartplus")); + assert(!serd_uri_string_has_scheme("-nostartminus")); + assert(!serd_uri_string_has_scheme(".nostartdot")); + assert(!serd_uri_string_has_scheme(":missing")); + assert(!serd_uri_string_has_scheme("a/slash/is/not/a/scheme/char")); + + assert(serd_uri_string_has_scheme("http://example.org/")); + assert(serd_uri_string_has_scheme("https://example.org/")); + assert(serd_uri_string_has_scheme("allapha:path")); + assert(serd_uri_string_has_scheme("w1thd1g1t5:path")); + assert(serd_uri_string_has_scheme("with.dot:path")); + assert(serd_uri_string_has_scheme("with+plus:path")); + assert(serd_uri_string_has_scheme("with-minus:path")); } static void @@ -44,14 +41,13 @@ test_file_uri(const char* const hostname, expected_path = path; } - SerdNode node = serd_node_new_file_uri(USTR(path), USTR(hostname), 0); - - uint8_t* out_hostname = NULL; - uint8_t* out_path = serd_file_uri_parse(node.buf, &out_hostname); - assert(!strcmp((const char*)node.buf, expected_uri)); + SerdNode node = serd_node_new_file_uri(path, hostname, 0); + char* out_hostname = NULL; + char* out_path = serd_file_uri_parse(node.buf, &out_hostname); + assert(!strcmp(node.buf, expected_uri)); assert((hostname && out_hostname) || (!hostname && !out_hostname)); - assert(!hostname || !strcmp(hostname, (const char*)out_hostname)); - assert(!strcmp((const char*)out_path, (const char*)expected_path)); + assert(!hostname || !strcmp(hostname, out_hostname)); + assert(!strcmp(out_path, expected_path)); serd_free(out_path); serd_free(out_hostname); @@ -107,8 +103,8 @@ test_uri_parsing(void) // Test tolerance of parsing junk URI escapes - uint8_t* out_path = serd_file_uri_parse(USTR("file:///foo/%0Xbar"), NULL); - assert(!strcmp((const char*)out_path, "/foo/bar")); + char* out_path = serd_file_uri_parse("file:///foo/%0Xbar", NULL); + assert(!strcmp(out_path, "/foo/bar")); serd_free(out_path); } @@ -120,13 +116,13 @@ test_uri_from_string(void) SerdURI base_uri; SerdNode base = - serd_node_new_uri_from_string(USTR("http://example.org/"), NULL, &base_uri); + 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(USTR(""), &base_uri, NULL); + SerdNode nil2 = serd_node_new_uri_from_string("", &base_uri, NULL); assert(nil.type == SERD_URI); - assert(!strcmp((const char*)nil.buf, (const char*)base.buf)); + assert(!strcmp(nil.buf, base.buf)); assert(nil2.type == SERD_URI); - assert(!strcmp((const char*)nil2.buf, (const char*)base.buf)); + assert(!strcmp(nil2.buf, base.buf)); serd_node_free(&nil); serd_node_free(&nil2); @@ -155,17 +151,14 @@ check_relative_uri(const char* const uri_string, SerdURI base = SERD_URI_NULL; SerdURI result = SERD_URI_NULL; - SerdNode uri_node = - serd_node_new_uri_from_string(USTR(uri_string), NULL, &uri); - - SerdNode base_node = - serd_node_new_uri_from_string(USTR(base_string), NULL, &base); + SerdNode uri_node = serd_node_new_uri_from_string(uri_string, NULL, &uri); + SerdNode base_node = serd_node_new_uri_from_string(base_string, NULL, &base); SerdNode result_node = SERD_NODE_NULL; if (root_string) { SerdURI root = SERD_URI_NULL; SerdNode root_node = - serd_node_new_uri_from_string(USTR(root_string), NULL, &root); + serd_node_new_uri_from_string(root_string, NULL, &root); result_node = serd_node_new_relative_uri(&uri, &base, &root, &result); serd_node_free(&root_node); @@ -176,7 +169,7 @@ check_relative_uri(const char* const uri_string, assert(!strcmp((const char*)result_node.buf, expected_string)); SerdURI expected = SERD_URI_NULL; - assert(!serd_uri_parse(USTR(expected_string), &expected)); + assert(!serd_uri_parse(expected_string, &expected)); assert(chunk_equals(&result.scheme, &expected.scheme)); assert(chunk_equals(&result.authority, &expected.authority)); assert(chunk_equals(&result.path_base, &expected.path_base)); diff --git a/test/test_writer.c b/test/test_writer.c index 0622dc82..7033db76 100644 --- a/test/test_writer.c +++ b/test/test_writer.c @@ -10,8 +10,6 @@ #include <stdio.h> #include <string.h> -#define USTR(s) ((const uint8_t*)(s)) - static void test_write_long_literal(void) { @@ -22,17 +20,16 @@ test_write_long_literal(void) assert(writer); - SerdNode s = serd_node_from_string(SERD_URI, USTR("http://example.org/s")); - SerdNode p = serd_node_from_string(SERD_URI, USTR("http://example.org/p")); - SerdNode o = - serd_node_from_string(SERD_LITERAL, USTR("hello \"\"\"world\"\"\"!")); + SerdNode s = serd_node_from_string(SERD_URI, "http://example.org/s"); + SerdNode p = serd_node_from_string(SERD_URI, "http://example.org/p"); + SerdNode o = serd_node_from_string(SERD_LITERAL, "hello \"\"\"world\"\"\"!"); assert(!serd_writer_write_statement(writer, 0, NULL, &s, &p, &o, NULL, NULL)); serd_writer_free(writer); serd_env_free(env); - uint8_t* out = serd_chunk_sink_finish(&chunk); + char* out = serd_chunk_sink_finish(&chunk); static const char* const expected = "<http://example.org/s>\n" @@ -59,9 +56,9 @@ test_writer_cleanup(void) SerdWriter* writer = serd_writer_new(SERD_TURTLE, (SerdStyle)0U, env, NULL, null_sink, NULL); - SerdNode s = serd_node_from_string(SERD_URI, USTR("http://example.org/s")); - SerdNode p = serd_node_from_string(SERD_URI, USTR("http://example.org/p")); - SerdNode o = serd_node_from_string(SERD_BLANK, USTR("http://example.org/o")); + SerdNode s = serd_node_from_string(SERD_URI, "http://example.org/s"); + SerdNode p = serd_node_from_string(SERD_URI, "http://example.org/p"); + SerdNode o = serd_node_from_string(SERD_BLANK, "http://example.org/o"); st = serd_writer_write_statement( writer, SERD_ANON_O_BEGIN, NULL, &s, &p, &o, NULL, NULL); @@ -73,7 +70,7 @@ test_writer_cleanup(void) char buf[12] = {0}; snprintf(buf, sizeof(buf), "b%u", i); - SerdNode next_o = serd_node_from_string(SERD_BLANK, USTR(buf)); + SerdNode next_o = serd_node_from_string(SERD_BLANK, buf); st = serd_writer_write_statement( writer, SERD_ANON_O_BEGIN, NULL, &o, &p, &next_o, NULL, NULL); @@ -107,11 +104,11 @@ test_strict_write(void) const uint8_t bad_str[] = {0xFF, 0x90, 'h', 'i', 0}; - SerdNode s = serd_node_from_string(SERD_URI, USTR("http://example.org/s")); - SerdNode p = serd_node_from_string(SERD_URI, USTR("http://example.org/p")); + SerdNode s = serd_node_from_string(SERD_URI, "http://example.org/s"); + SerdNode p = serd_node_from_string(SERD_URI, "http://example.org/p"); - 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_from_string(SERD_LITERAL, (const char*)bad_str); + SerdNode bad_uri = serd_node_from_string(SERD_URI, (const char*)bad_str); assert(serd_writer_write_statement( writer, 0, NULL, &s, &p, &bad_lit, NULL, NULL) == SERD_ERR_BAD_TEXT); @@ -142,7 +139,7 @@ test_write_error(void) SerdWriter* writer = NULL; SerdStatus st = SERD_SUCCESS; - SerdNode u = serd_node_from_string(SERD_URI, USTR("http://example.com/u")); + SerdNode u = serd_node_from_string(SERD_URI, "http://example.com/u"); writer = serd_writer_new(SERD_TURTLE, (SerdStyle)0, env, NULL, error_sink, NULL); |