Commit 7eaa5416 authored by Christian Kellner's avatar Christian Kellner

common: bolt_strv_isempty helper added

Check if the supplied string vector is NULL or contains zero
elements. Currently implemented as macro, not inline function,
due to const correctness and nested pointer types.
parent 15515c85
......@@ -45,6 +45,8 @@ GHashTable * bolt_strv_diff (const GStrv before,
char ** bolt_strv_rotate_left (char **strv);
void bolt_strv_permute (char **strv);
#define bolt_strv_isempty(strv) ((strv) == NULL || *(strv) == NULL)
#define bolt_strzero(str) (str == NULL || *str == '\0')
#define bolt_yesno(val) val ? "yes" : "no"
......
......@@ -1173,7 +1173,14 @@ test_strv_length (TestRng *tt, gconstpointer user_data)
};
for (gsize i = 0; i < G_N_ELEMENTS (table); i++)
g_assert_cmpuint (bolt_strv_length (table[i].strv), ==, table[i].l);
{
g_assert_cmpuint (bolt_strv_length (table[i].strv), ==, table[i].l);
if (table[i].l == 0)
g_assert_true (bolt_strv_isempty (table[i].strv));
else
g_assert_false (bolt_strv_isempty (table[i].strv));
}
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment