This source file includes following definitions.
- bad_input
 
- ends_with
 
- ends_with_ext
 
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 #include <crm_internal.h>
  11 
  12 #include <crm/common/unittest_internal.h>
  13 
  14 static void
  15 bad_input(void **state) {
     
  16     assert_false(pcmk__ends_with(NULL, "xyz"));
  17 
  18     assert_true(pcmk__ends_with(NULL, NULL));
  19     assert_true(pcmk__ends_with(NULL, ""));
  20     assert_true(pcmk__ends_with("", NULL));
  21     assert_true(pcmk__ends_with("", ""));
  22     assert_true(pcmk__ends_with("abc", NULL));
  23     assert_true(pcmk__ends_with("abc", ""));
  24 }
  25 
  26 static void
  27 ends_with(void **state) {
     
  28     assert_true(pcmk__ends_with("abc", "abc"));
  29     assert_true(pcmk__ends_with("abc", "bc"));
  30     assert_true(pcmk__ends_with("abc", "c"));
  31     assert_true(pcmk__ends_with("abcbc", "bc"));
  32 
  33     assert_false(pcmk__ends_with("abc", "def"));
  34     assert_false(pcmk__ends_with("abc", "defg"));
  35     assert_false(pcmk__ends_with("abc", "bcd"));
  36     assert_false(pcmk__ends_with("abc", "ab"));
  37 
  38     assert_false(pcmk__ends_with("abc", "BC"));
  39 }
  40 
  41 static void
  42 ends_with_ext(void **state) {
     
  43     assert_true(pcmk__ends_with_ext("ab.c", ".c"));
  44     assert_true(pcmk__ends_with_ext("ab.cb.c", ".c"));
  45 
  46     assert_false(pcmk__ends_with_ext("ab.c", ".def"));
  47     assert_false(pcmk__ends_with_ext("ab.c", ".defg"));
  48     assert_false(pcmk__ends_with_ext("ab.c", ".cd"));
  49     assert_false(pcmk__ends_with_ext("ab.c", "ab"));
  50 
  51     assert_false(pcmk__ends_with_ext("ab.c", ".C"));
  52 }
  53 
  54 PCMK__UNIT_TEST(NULL, NULL,
  55                 cmocka_unit_test(bad_input),
  56                 cmocka_unit_test(ends_with),
  57                 cmocka_unit_test(ends_with_ext))