aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_uri.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-03-16 16:21:20 -0400
committerDavid Robillard <d@drobilla.net>2021-03-07 15:32:23 -0500
commita29581d3ba664175c459e20e6c86be09707fde6e (patch)
treed11253ca88b09d7a768740b00332a4d780e3852d /test/test_uri.c
parent6e856d3e7a9c3162b9af350d5cec8a3f6bb94ee2 (diff)
downloadserd-a29581d3ba664175c459e20e6c86be09707fde6e.tar.gz
serd-a29581d3ba664175c459e20e6c86be09707fde6e.tar.bz2
serd-a29581d3ba664175c459e20e6c86be09707fde6e.zip
Use char* for strings in public API
The constant casting just makes user code a mess, for no benefit.
Diffstat (limited to 'test/test_uri.c')
-rw-r--r--test/test_uri.c46
1 files changed, 20 insertions, 26 deletions
diff --git a/test/test_uri.c b/test/test_uri.c
index 554b4a93..8c3ec5a4 100644
--- a/test/test_uri.c
+++ b/test/test_uri.c
@@ -19,12 +19,9 @@
#include "serd/serd.h"
#include <assert.h>
-#include <stdint.h>
#include <stdio.h>
#include <string.h>
-#define USTR(s) ((const uint8_t*)(s))
-
static void
test_file_uri(const char* hostname,
const char* path,
@@ -35,13 +32,12 @@ test_file_uri(const char* 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(!strcmp((const char*)out_path, (const char*)expected_path));
+ assert(!strcmp(out_path, expected_path));
serd_free(out_path);
serd_free(out_hostname);
@@ -62,8 +58,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);
}
@@ -75,13 +71,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);
@@ -93,32 +89,30 @@ test_relative_uri(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 abs =
- serd_node_from_string(SERD_URI, USTR("http://example.org/foo/bar"));
- SerdURI abs_uri;
+ SerdNode abs = serd_node_from_string(SERD_URI, "http://example.org/foo/bar");
+ SerdURI abs_uri;
serd_uri_parse(abs.buf, &abs_uri);
SerdURI rel_uri;
SerdNode rel =
serd_node_new_relative_uri(&abs_uri, &base_uri, NULL, &rel_uri);
- assert(!strcmp((const char*)rel.buf, "/foo/bar"));
+ assert(!strcmp(rel.buf, "/foo/bar"));
SerdNode up = serd_node_new_relative_uri(&base_uri, &abs_uri, NULL, NULL);
- assert(!strcmp((const char*)up.buf, "../"));
+ assert(!strcmp(up.buf, "../"));
SerdNode noup =
serd_node_new_relative_uri(&base_uri, &abs_uri, &abs_uri, NULL);
- assert(!strcmp((const char*)noup.buf, "http://example.org/"));
+ assert(!strcmp(noup.buf, "http://example.org/"));
- SerdNode x =
- serd_node_from_string(SERD_URI, USTR("http://example.org/foo/x"));
- SerdURI x_uri;
+ SerdNode x = serd_node_from_string(SERD_URI, "http://example.org/foo/x");
+ SerdURI x_uri;
serd_uri_parse(x.buf, &x_uri);
SerdNode x_rel = serd_node_new_relative_uri(&x_uri, &abs_uri, &abs_uri, NULL);
- assert(!strcmp((const char*)x_rel.buf, "x"));
+ assert(!strcmp(x_rel.buf, "x"));
serd_node_free(&x_rel);
serd_node_free(&noup);