12 #include <sys/types.h>
21 pcmk__add_word(&list, &list_len,
"hello");
22 pcmk__add_word(&list, &list_len,
"world");
23 g_assert_cmpint(strcmp(list,
"hello world"), ==, 0);
32 pcmk__add_word(&list, NULL,
"hello");
33 pcmk__add_word(&list, NULL,
"world");
34 g_assert_cmpint(strcmp(list,
"hello world"), ==, 0);
43 pcmk__add_word(&list, NULL,
"hello");
44 pcmk__add_word(&list, NULL, NULL);
45 pcmk__add_word(&list, NULL,
"");
46 g_assert_cmpint(strcmp(list,
"hello"), ==, 0);
59 g_assert_cmpint(strcmp(list,
"hello world I am a unit test"), ==, 0);
72 g_assert_cmpint(strcmp(list,
"hello,world,I am a unit test"), ==, 0);
77 add_with_comma_and_space(
void)
85 g_assert_cmpint(strcmp(list,
"hello, world, I am a unit test"), ==, 0);
90 main(
int argc,
char **argv)
92 g_test_init(&argc, &argv, NULL);
94 g_test_add_func(
"/common/strings/add_word/add_words", add_words);
95 g_test_add_func(
"/common/strings/add_word/add_with_no_len",
97 g_test_add_func(
"/common/strings/add_word/add_nothing", add_nothing);
98 g_test_add_func(
"/common/strings/add_word/add_with_null", add_with_null);
99 g_test_add_func(
"/common/strings/add_word/add_with_comma", add_with_comma);
100 g_test_add_func(
"/common/strings/add_word/add_with_comma_and_space",
101 add_with_comma_and_space);
void pcmk__add_separated_word(char **list, size_t *len, const char *word, const char *separator)
int main(int argc, char **argv)