root/lib/common/tests/lists/pcmk__list_of_multiple_test.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. empty_list
  2. singleton_list
  3. longer_list

   1 /*
   2  * Copyright 2022 the Pacemaker project contributors
   3  *
   4  * The version control history for this file may have further details.
   5  *
   6  * This source code is licensed under the GNU General Public License version 2
   7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #include <crm_internal.h>
  11 
  12 #include <crm/common/unittest_internal.h>
  13 
  14 #include <glib.h>
  15 
  16 static void
  17 empty_list(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  18     assert_false(pcmk__list_of_multiple(NULL));
  19 }
  20 
  21 static void
  22 singleton_list(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  23     GList *lst = NULL;
  24 
  25     lst = g_list_append(lst, strdup("abc"));
  26     assert_false(pcmk__list_of_multiple(lst));
  27 
  28     g_list_free_full(lst, free);
  29 }
  30 
  31 static void
  32 longer_list(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  33     GList *lst = NULL;
  34 
  35     lst = g_list_append(lst, strdup("abc"));
  36     lst = g_list_append(lst, strdup("xyz"));
  37     assert_true(pcmk__list_of_multiple(lst));
  38 
  39     g_list_free_full(lst, free);
  40 }
  41 
  42 PCMK__UNIT_TEST(NULL, NULL,
  43                 cmocka_unit_test(empty_list),
  44                 cmocka_unit_test(singleton_list),
  45                 cmocka_unit_test(longer_list))

/* [previous][next][first][last][top][bottom][index][help] */