* add mu_str_replace

This commit is contained in:
djcb
2013-05-26 11:16:02 -07:00
parent 52d89bd1f8
commit 3dae623879
3 changed files with 75 additions and 0 deletions

View File

@ -431,6 +431,35 @@ test_mu_term_fixups (void)
static void
test_mu_str_replace (void)
{
unsigned u;
struct {
const char* str;
const char* sub;
const char *repl;
const char *exp;
} strings [] = {
{ "hello", "ll", "xx", "hexxo" },
{ "hello", "hello", "hi", "hi" },
{ "hello", "foo", "bar", "hello" }
};
for (u = 0; u != G_N_ELEMENTS(strings); ++u) {
char *res;
res = mu_str_replace (strings[u].str,
strings[u].sub,
strings[u].repl);
g_assert_cmpstr (res,==,strings[u].exp);
g_free (res);
}
}
int
main (int argc, char *argv[])
{
@ -471,6 +500,9 @@ main (int argc, char *argv[])
g_test_add_func ("/mu-str/mu-str-esc-to-list",
test_parse_arglist);
g_test_add_func ("/mu-str/mu-str-replace",
test_mu_str_replace);
g_test_add_func ("/mu-str/mu-str-esc-to-list",
test_mu_str_esc_to_list);