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);
31 pcmk__add_word(&list, NULL,
"hello");
32 pcmk__add_word(&list, NULL,
"world");
33 g_assert_cmpint(strcmp(list,
"hello world"), ==, 0);
41 pcmk__add_word(&list, NULL,
"hello");
42 pcmk__add_word(&list, NULL, NULL);
43 pcmk__add_word(&list, NULL,
"");
44 g_assert_cmpint(strcmp(list,
"hello"), ==, 0);
56 g_assert_cmpint(strcmp(list,
"hello world I am a unit test"), ==, 0);
68 g_assert_cmpint(strcmp(list,
"hello,world,I am a unit test"), ==, 0);
72 add_with_comma_and_space(
void)
80 g_assert_cmpint(strcmp(list,
"hello, world, I am a unit test"), ==, 0);
84 main(
int argc,
char **argv)
86 g_test_init(&argc, &argv, NULL);
88 g_test_add_func(
"/common/strings/add_word/add_words", add_words);
89 g_test_add_func(
"/common/strings/add_word/add_with_no_len",
91 g_test_add_func(
"/common/strings/add_word/add_nothing", add_nothing);
92 g_test_add_func(
"/common/strings/add_word/add_with_null", add_with_null);
93 g_test_add_func(
"/common/strings/add_word/add_with_comma", add_with_comma);
94 g_test_add_func(
"/common/strings/add_word/add_with_comma_and_space",
95 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)