From 17f9487ed0d169f619f87eb98185665708250fc1 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 23 Dec 2012 01:13:07 +0000 Subject: Fix serd_node_new_decimal test code. git-svn-id: http://svn.drobilla.net/serd/trunk@402 490d8e77-9747-427b-9fa3-0b8f29cee8a0 --- tests/serd_test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/serd_test.c') 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); -- cgit v1.2.1