aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-03-15 23:37:09 -0400
committerDavid Robillard <d@drobilla.net>2018-05-27 18:18:30 +0200
commit88ea0c449a8daa8951eca0ae69fd376f86122982 (patch)
treecf95d8fc4f7249498246aa815002ea0293cad713 /tests
parent9b3d8263604ba11ae008c8651a1fe2063296d6b1 (diff)
downloadserd-88ea0c449a8daa8951eca0ae69fd376f86122982.tar.gz
serd-88ea0c449a8daa8951eca0ae69fd376f86122982.tar.bz2
serd-88ea0c449a8daa8951eca0ae69fd376f86122982.zip
Remove useless character counting
Diffstat (limited to 'tests')
-rw-r--r--tests/serd_test.c49
1 files changed, 18 insertions, 31 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c
index 62621e16..71801c1b 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -163,9 +163,9 @@ main(void)
node.buf, dbl_test_strs[i]);
}
const size_t len = node.buf ? strlen((const char*)node.buf) : 0;
- if (node.n_bytes != len || node.n_chars != len) {
- FAILF("Length %zu,%zu != %zu\n",
- node.n_bytes, node.n_chars, len);
+ if (node.n_bytes != len) {
+ FAILF("Length %zu != %zu\n",
+ node.n_bytes, len);
}
serd_node_free(&node);
}
@@ -187,9 +187,9 @@ main(void)
node.buf, int_test_strs[i]);
}
const size_t len = strlen((const char*)node.buf);
- if (node.n_bytes != len || node.n_chars != len) {
+ if (node.n_bytes != len) {
FAILF("Length %zu,%zu != %zu\n",
- node.n_bytes, node.n_chars, len);
+ node.n_bytes, len);
}
serd_node_free(&node);
}
@@ -202,12 +202,6 @@ main(void)
}
SerdNode blob = serd_node_new_blob(data, size, size % 5);
-
- if (blob.n_bytes != blob.n_chars) {
- FAILF("Blob %zu bytes != %zu chars\n",
- blob.n_bytes, blob.n_chars);
- }
-
size_t out_size;
uint8_t* out = (uint8_t*)serd_base64_decode(
blob.buf, blob.n_bytes, &out_size);
@@ -230,18 +224,11 @@ main(void)
const uint8_t str[] = { '"', '5', 0xE2, 0x82, 0xAC, '"', '\n', 0 };
- size_t n_bytes;
SerdNodeFlags flags;
- size_t len = serd_strlen(str, &n_bytes, &flags);
- if (len != 5 || n_bytes != 7
- || flags != (SERD_HAS_QUOTE|SERD_HAS_NEWLINE)) {
- FAILF("Bad serd_strlen(%s) len=%zu n_bytes=%zu flags=%u\n",
- str, len, n_bytes, flags);
- }
- len = serd_strlen(str, NULL, &flags);
- if (len != 5) {
- FAILF("Bad serd_strlen(%s) len=%zu flags=%u\n",
- str, len, flags);
+ size_t n_bytes = serd_strlen(str, &flags);
+ if (n_bytes != 7 || flags != (SERD_HAS_QUOTE|SERD_HAS_NEWLINE)) {
+ FAILF("Bad serd_strlen(%s) n_bytes=%zu flags=%u\n",
+ str, n_bytes, flags);
}
// Test serd_strerror
@@ -346,10 +333,10 @@ main(void)
// Test serd_node_from_string
SerdNode node = serd_node_from_string(SERD_LITERAL, (const uint8_t*)"hello\"");
- if (node.n_bytes != 6 || node.n_chars != 6 || node.flags != SERD_HAS_QUOTE
+ if (node.n_bytes != 6 || node.flags != SERD_HAS_QUOTE
|| strcmp((const char*)node.buf, "hello\"")) {
- FAILF("Bad node %s %zu %zu %d %d\n",
- node.buf, node.n_bytes, node.n_chars, node.flags, node.type);
+ FAILF("Bad node %s %zu %d %d\n",
+ node.buf, node.n_bytes, node.flags, node.type);
}
node = serd_node_from_string(SERD_URI, NULL);
@@ -360,22 +347,22 @@ main(void)
// Test serd_node_from_substring
SerdNode empty = serd_node_from_substring(SERD_LITERAL, NULL, 32);
- if (empty.buf || empty.n_bytes || empty.n_chars || empty.flags || empty.type) {
+ if (empty.buf || empty.n_bytes || empty.flags || empty.type) {
FAIL("Successfully created node from NULL substring\n");
}
SerdNode a_b = serd_node_from_substring(SERD_LITERAL, USTR("a\"bc"), 3);
- if (a_b.n_bytes != 3 || a_b.n_chars != 3 || a_b.flags != SERD_HAS_QUOTE
+ 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 %zu %d %d\n",
- a_b.buf, a_b.n_bytes, a_b.n_chars, a_b.flags, a_b.type);
+ FAILF("Bad node %s %zu %d %d\n",
+ a_b.buf, a_b.n_bytes, a_b.flags, a_b.type);
}
a_b = serd_node_from_substring(SERD_LITERAL, USTR("a\"bc"), 10);
- if (a_b.n_bytes != 4 || a_b.n_chars != 4 || a_b.flags != SERD_HAS_QUOTE
+ 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.n_chars, a_b.flags, a_b.type);
+ a_b.buf, a_b.n_bytes, a_b.flags, a_b.type);
}
// Test serd_node_new_uri_from_string