mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 14:38:09 +02:00
glib-aux/tests: add nmtst_true_once() helper
This commit is contained in:
parent
e03b8fa447
commit
67ee036389
1 changed files with 22 additions and 0 deletions
|
|
@ -1191,6 +1191,28 @@ nmtst_get_rand_word_length(GRand *rand)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline gboolean
|
||||
nmtst_true_once(gboolean *state, gboolean new_val)
|
||||
{
|
||||
/* Returns only once a TRUE flag. When returning TRUE,
|
||||
* it will be remembered in "state" and future invocations
|
||||
* return FALSE.
|
||||
*
|
||||
* Also, if "new_val" is FALSE, it won't return TRUE.
|
||||
*
|
||||
* The point is to do an action once (depending on "new_val"),
|
||||
* and remember it in "state".
|
||||
*/
|
||||
if (!new_val)
|
||||
return FALSE;
|
||||
if (*state)
|
||||
return FALSE;
|
||||
*state = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline gboolean
|
||||
nmtst_g_source_assert_not_called(gpointer user_data)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue