Skip to content

Use better assertions

Simon McVittie requested to merge wip/smcv/better-assertions into master

This avoids the assertions being removed by G_DISABLE_ASSERT, and gives somewhat better diagnostic messages if the assertion fails.

Note that in the files in dbus/, ordinary runtime assertions are deliberately not replaced. The only assertions replaced here are in the extra code that gets built into the library by --enable-tests.

  • test: Replace all g_assert (x != NULL) with g_assert_nonnull (x)

  • test: Replace g_assert (x == NULL) with g_assert_null (x)

  • test: Compare strings with g_assert_cmpstr()

  • test: Compare integers using g_assert_cmpint(), g_assert_cmpuint()

  • test: Use g_assert_true, g_assert_false for comparisons with TRUE, FALSE

  • test: Replace remaining g_assert (!x) with g_assert_false (x)

  • test: Replace remaining assertions with g_assert_true()

Related to #16 (closed).

Merge request reports