diff options
author | David Robillard <d@drobilla.net> | 2016-03-15 23:37:09 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-11-25 09:21:03 +0100 |
commit | d70d76deeb5735f97bb90792d5200ee812fb50b0 (patch) | |
tree | 45704de9956c4e96db0dfd686d94876b720cb96b /tests | |
parent | f046eb982627f344fc0eeff6be82028318862e67 (diff) | |
download | serd-d70d76deeb5735f97bb90792d5200ee812fb50b0.tar.gz serd-d70d76deeb5735f97bb90792d5200ee812fb50b0.tar.bz2 serd-d70d76deeb5735f97bb90792d5200ee812fb50b0.zip |
Remove useless character counting
Diffstat (limited to 'tests')
-rw-r--r-- | tests/serd_test.c | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c index 0ffcdf51..c65e44b7 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); } @@ -203,10 +203,7 @@ 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); - } else if (blob.n_bytes != strlen((const char*)blob.buf)) { + if (blob.n_bytes != strlen((const char*)blob.buf)) { FAILF("Blob %zu bytes != length %zu\n", blob.n_bytes, strlen((const char*)blob.buf)); } @@ -233,22 +230,15 @@ 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); } - if (serd_strlen(str, &n_bytes, NULL) != 5) { - FAILF("Bad serd_strlen(%s) n_bytes=%zu no flags\n", str, n_bytes); + if (serd_strlen(str, NULL) != 7) { + FAILF("Bad serd_strlen(%s) no flags\n", str, n_bytes); } // Test serd_strerror @@ -353,10 +343,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); @@ -367,22 +357,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 |