From 022ae9c2e39c321bd8b532b34a2b3e85bce47dd0 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Tue, 31 May 2022 23:39:50 +0300 Subject: [PATCH] result: make assert_valid_result a bit more informative For unit tests. --- lib/utils/mu-result.hh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/utils/mu-result.hh b/lib/utils/mu-result.hh index d63967ef..ee709f13 100644 --- a/lib/utils/mu-result.hh +++ b/lib/utils/mu-result.hh @@ -136,13 +136,19 @@ Err(Error::Code errcode, GError **err, const char* frm, ...) - -#define assert_valid_result(R) do { \ - if(!R) { \ - g_critical("error-result: %s", (R).error().what()); \ - } \ - } \ - while(0) +/** + * Assert that some result has a value (for unit tests) + * + * @param R some result + */ +#define assert_valid_result(R) do { \ + if(!R) { \ + g_printerr("%s:%u: error-result: %s\n", \ + __FILE__, __LINE__, \ + (R).error().what()); \ + g_assert_true(!!R); \ + } \ +} while(0)