root/lib/common/tests/output/pcmk__unregister_formats_test.c

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

DEFINITIONS

This source file includes following definitions.
  1. null_create_fn
  2. invalid_params
  3. non_null_formatters

   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 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 <crm/common/unittest_internal.h>
  13 #include <crm/common/output_internal.h>
  14 
  15 static pcmk__output_t *
  16 null_create_fn(char **argv) {
     /* [previous][next][first][last][top][bottom][index][help] */
  17     return NULL;
  18 }
  19 
  20 static void
  21 invalid_params(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  22     /* This is basically just here to make sure that calling pcmk__unregister_formats
  23      * with formatters=NULL doesn't segfault.
  24      */
  25     pcmk__unregister_formats();
  26     assert_null(pcmk__output_formatters());
  27 }
  28 
  29 static void
  30 non_null_formatters(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  31     pcmk__register_format(NULL, "fake", null_create_fn, NULL);
  32 
  33     pcmk__unregister_formats();
  34     assert_null(pcmk__output_formatters());
  35 }
  36 
  37 PCMK__UNIT_TEST(NULL, NULL,
  38                 cmocka_unit_test(invalid_params),
  39                 cmocka_unit_test(non_null_formatters))

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