test-strfuncs.c revision be1749e2421dea6465f9096fd35b28b2500d06e4
bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2009-2015 Dovecot authors, see the included COPYING file */
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainenstatic void test_p_strarray_dup(void)
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen const char **ret;
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen unsigned int i, j;
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen test_assert(strcmp(input[i][j], ret[j]) == 0);
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainenstatic void test_t_strsplit(void)
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen const char *const *args;
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen /* empty string -> empty array. was this perhaps a mistake for the
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen API to do this originally?.. can't really change now anyway. */
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen /* two empty strings */
1139a1f61032e3b81bd1c7f526b9e9553f51a5a8Timo Sirainen unsigned int i;
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainenstatic void test_t_strsplit_tab(void)
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen unsigned int i, j, max;
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen for (j = 0; j < 256; j++) {
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen for (j = 0; j < 100; j++) {
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen for (i = 0; i < max; i++) {
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainenstatic void test_t_str_replace(void)
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen test_assert(strcmp(t_str_replace("foo", 'a', 'b'), "foo") == 0);
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen test_assert(strcmp(t_str_replace("fooa", 'a', 'b'), "foob") == 0);
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen test_assert(strcmp(t_str_replace("afooa", 'a', 'b'), "bfoob") == 0);
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen test_assert(strcmp(t_str_replace("", 'a', 'b'), "") == 0);
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen test_assert(strcmp(t_str_replace("a", 'a', 'b'), "b") == 0);
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen test_assert(strcmp(t_str_replace("aaa", 'a', 'b'), "bbb") == 0);
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen test_assert(strcmp(t_str_replace("bbb", 'a', 'b'), "bbb") == 0);
9761e0036c87f459abe040632e1252f794ffe5f7Timo Sirainen test_assert(strcmp(t_str_replace("aba", 'a', 'b'), "bbb") == 0);