From 7dfe951f220cefdd6d40b575d26fb38fd43a0a2f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 11 Dec 2024 12:56:06 -0500 Subject: Avoid assignments in assert statements The ways these tests are written fundamentally requires assertions to always run, but some tools like to warn about it anyway, so avoid obvious cases. --- test/test_writer.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/test_writer.c b/test/test_writer.c index e3aba50c..6590ba4a 100644 --- a/test/test_writer.c +++ b/test/test_writer.c @@ -166,10 +166,12 @@ test_writer_cleanup(void) } // Finish writing without terminating nodes - assert(!(st = serd_writer_finish(writer))); + st = serd_writer_finish(writer); + assert(!st); // Set the base to an empty URI - assert(!(st = serd_writer_set_base_uri(writer, NULL))); + st = serd_writer_set_base_uri(writer, NULL); + assert(!st); // Free (which could leak if the writer doesn't clean up the stack properly) serd_writer_free(writer); @@ -190,8 +192,9 @@ test_write_bad_anon_stack(void) SerdNode b1 = serd_node_from_string(SERD_BLANK, USTR("b1")); SerdNode b2 = serd_node_from_string(SERD_BLANK, USTR("b2")); - assert(!(st = serd_writer_write_statement( - writer, SERD_ANON_O_BEGIN, NULL, &s, &p, &b0, NULL, NULL))); + st = serd_writer_write_statement( + writer, SERD_ANON_O_BEGIN, NULL, &s, &p, &b0, NULL, NULL); + assert(!st); // (missing call to end the anonymous node here) @@ -200,7 +203,8 @@ test_write_bad_anon_stack(void) assert(st == SERD_ERR_BAD_ARG); - assert(!(st = serd_writer_finish(writer))); + st = serd_writer_finish(writer); + assert(!st); serd_writer_free(writer); serd_env_free(env); } -- cgit v1.2.1