root/lib/common/tests/flags/pcmk_all_flags_set_test.c

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

DEFINITIONS

This source file includes following definitions.
  1. all_set
  2. one_is_set
  3. main

   1 /*
   2  * Copyright 2020-2021 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 Lesser General Public License
   7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #include <crm_internal.h>
  11 
  12 #include <stdarg.h>
  13 #include <stddef.h>
  14 #include <stdint.h>
  15 #include <setjmp.h>
  16 #include <cmocka.h>
  17 
  18 static void
  19 all_set(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  20     assert_false(pcmk_all_flags_set(0x000, 0x003));
  21     assert_true(pcmk_all_flags_set(0x00f, 0x003));
  22     assert_false(pcmk_all_flags_set(0x00f, 0x010));
  23     assert_false(pcmk_all_flags_set(0x00f, 0x011));
  24     assert_true(pcmk_all_flags_set(0x000, 0x000));
  25     assert_true(pcmk_all_flags_set(0x00f, 0x000));
  26 }
  27 
  28 static void
  29 one_is_set(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  30     // pcmk_is_set() is a simple macro alias for pcmk_all_flags_set()
  31     assert_true(pcmk_is_set(0x00f, 0x001));
  32     assert_false(pcmk_is_set(0x00f, 0x010));
  33 }
  34 
  35 int
  36 main(int argc, char **argv)
     /* [previous][next][first][last][top][bottom][index][help] */
  37 {
  38     const struct CMUnitTest tests[] = {
  39         cmocka_unit_test(all_set),
  40         cmocka_unit_test(one_is_set),
  41     };
  42 
  43     cmocka_set_message_output(CM_OUTPUT_TAP);
  44     return cmocka_run_group_tests(tests, NULL, NULL);
  45 }

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