* let mu_str_subject_normalize work with static strings as well

This commit is contained in:
Dirk-Jan C. Binnema 2011-07-02 12:48:46 +03:00
parent a2bc4540e0
commit 58fdfa9bc1
3 changed files with 38 additions and 8 deletions

View File

@ -439,8 +439,13 @@ mu_str_subject_normalize (const gchar* str)
last_colon = g_strrstr (str, ":");
if (!last_colon)
return str;
else
return g_strchug (last_colon + 1);
else {
gchar *str;
str = last_colon + 1;
while (*str == ' ')
++str;
return str;
}
}

View File

@ -324,7 +324,6 @@ test_mu_msg_tags (void)
g_assert_cmpstr ((char*)tags->data,==,"paradise");
g_assert_cmpstr ((char*)tags->next->data,==,"lost");
g_assert (tags->next->next == NULL);
mu_msg_unref (msg);
}

View File

@ -412,6 +412,28 @@ test_mu_str_guess_nick (void)
static void
test_mu_str_subject_normalize (void)
{
int i;
struct {
char *src, *exp;
} tests[] = {
{ "test123", "test123" },
{ "Re:test123", "test123" },
{ "Re: Fwd: test123", "test123" },
{ "Re[3]: Fwd: test123", "test123" },
{ "operation: mindcrime", "mindcrime" }, /*...*/
{ "", "" }
};
for (i = 0; i != G_N_ELEMENTS(tests); ++i)
g_assert_cmpstr (mu_str_subject_normalize (tests[i].src), ==,
tests[i].exp);
}
@ -453,16 +475,20 @@ main (int argc, char *argv[])
g_test_add_func ("/mu-str/mu-str-to-list",
test_mu_str_to_list);
g_test_add_func ("/mu-str/mu-str_date_parse_hdwmy",
g_test_add_func ("/mu-str/mu_str_date_parse_hdwmy",
test_mu_str_date_parse_hdwmy);
g_test_add_func ("/mu-str/mu-str_guess_first_name",
g_test_add_func ("/mu-str/mu_str_guess_first_name",
test_mu_str_guess_first_name);
g_test_add_func ("/mu-str/mu-str_guess_last_name",
g_test_add_func ("/mu-str/mu_str_guess_last_name",
test_mu_str_guess_last_name);
g_test_add_func ("/mu-str/mu-str_guess_nick",
g_test_add_func ("/mu-str/mu_str_guess_nick",
test_mu_str_guess_nick);
g_test_add_func ("/mu-str/mu_str_subject_normalize",
test_mu_str_subject_normalize);
/* FIXME: add tests for mu_str_flags; but note the
* function simply calls mu_msg_field_str */