aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-12-23 01:13:07 +0000
committerDavid Robillard <d@drobilla.net>2012-12-23 01:13:07 +0000
commit17f9487ed0d169f619f87eb98185665708250fc1 (patch)
treeea112608b44ef6e3b2ba7c55e16976ad74e0b0ed /tests
parent73d0a86698528bf73d029e35a57ce7b38783cf2a (diff)
downloadserd-17f9487ed0d169f619f87eb98185665708250fc1.tar.gz
serd-17f9487ed0d169f619f87eb98185665708250fc1.tar.bz2
serd-17f9487ed0d169f619f87eb98185665708250fc1.zip
Fix serd_node_new_decimal test code.
git-svn-id: http://svn.drobilla.net/serd/trunk@402 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'tests')
-rw-r--r--tests/serd_test.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c
index f53e3494..5e37824c 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -122,15 +122,15 @@ main(void)
};
for (unsigned i = 0; i < sizeof(dbl_test_nums) / sizeof(double); ++i) {
- SerdNode node = serd_node_new_decimal(dbl_test_nums[i], 8);
- if (node.buf == dbl_test_strs[i]) {
- continue;
- }
- if (strcmp((const char*)node.buf, (const char*)dbl_test_strs[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, (const char*)dbl_test_strs[i])
+ : ((const char*)node.buf == dbl_test_strs[i]);
+ if (!pass) {
return failure("Serialised `%s' != %s\n",
node.buf, dbl_test_strs[i]);
}
- const size_t len = strlen((const char*)node.buf);
+ const size_t len = node.buf ? strlen((const char*)node.buf) : 0;
if (node.n_bytes != len || node.n_chars != len) {
return failure("Length %zu,%zu != %zu\n",
node.n_bytes, node.n_chars, len);