On Thu, May 11, 2023 at 09:10:15PM -0500, Eric Blake wrote:
> glib documentation[1] is clear: g_assert() should be avoided in unit
> tests because it is ineffective if G_DISABLE_ASSERT is defined; unit
> tests should stick to constructs based on g_assert_true() instead.
> Note that since commit 262a69f428, we intentionally state that you
> cannot define G_DISABLE_ASSERT that while building qemu; but our code

s/that //

> can be copied to other projects without that restriction, so we should
> be consistent.
> 
> For most of the replacements in this patch, using g_assert_cmpstr()
> would be a regression in quality - although it would helpfully display
> the string contents of both pointers on test failure, here, we really
> do care about pointer equality, not just string content equality.  But
> when a NULL pointer is expected, g_assert_null works fine.
> 
> [1] https://libsoup.org/glib/glib-Testing.html#g-assert
> 
> Signed-off-by: Eric Blake <ebl...@redhat.com>
> Reviewed-by: Hanna Czenczek <hre...@redhat.com>
> ---
>  tests/unit/test-cutils.c | 324 +++++++++++++++++++--------------------
>  1 file changed, 162 insertions(+), 162 deletions(-)
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


Reply via email to