aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_node.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_node.c')
-rw-r--r--test/test_node.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/test/test_node.c b/test/test_node.c
index d0302680..ac0a02ae 100644
--- a/test/test_node.c
+++ b/test/test_node.c
@@ -27,8 +27,6 @@
#include <stdlib.h>
#include <string.h>
-#define USTR(s) ((const uint8_t*)(s))
-
#ifndef INFINITY
# define INFINITY (DBL_MAX + DBL_MAX)
#endif
@@ -95,10 +93,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);
}
@@ -114,9 +112,8 @@ test_integer_to_node(void)
for (size_t i = 0; i < sizeof(int_test_nums) / sizeof(double); ++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);
}
}
@@ -132,7 +129,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 =
@@ -153,11 +150,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));
@@ -168,8 +166,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\""));
@@ -184,13 +183,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