* mu-msg-str: re-implement mu_msg_str_normalize by hand to actually work, add

unit tests
This commit is contained in:
Dirk-Jan C. Binnema
2010-11-11 22:04:47 +02:00
parent fd2df0199c
commit be0683526f
2 changed files with 142 additions and 16 deletions

View File

@ -121,9 +121,37 @@ test_mu_msg_str_prio_02 (void)
{
/* this must fail */
g_test_log_set_fatal_handler ((GTestLogFatalFunc)ignore_error, NULL);
g_assert_cmpstr (mu_msg_str_prio(666), ==, NULL);
}
static void
test_mu_msg_str_normalize_01 (void)
{
int i;
struct {
const char* word;
const char* norm;
} words [] = {
{ "dantès", "dantes"},
{ "foo", "foo" },
{ "Föö", "foo" },
{ "hÆvý mëÐal ümláõt", "haevy medal umlaot"}
};
for (i = 0; i != G_N_ELEMENTS(words); ++i) {
gchar *str;
str = mu_msg_str_normalize (words[i].word, TRUE);
g_assert_cmpstr (str, ==, words[i].norm);
g_free (str);
}
}
int
main (int argc, char *argv[])
@ -146,6 +174,11 @@ main (int argc, char *argv[])
g_test_add_func ("/mu-msg-str/mu-msg-str-prio-02",
test_mu_msg_str_prio_02);
/* mu_msg_str_normalize */
g_test_add_func ("/mu-msg-str/mu-msg-str-normalize-01",
test_mu_msg_str_normalize_01);
/* FIXME: add tests for mu_msg_str_flags; but note the
* function simply calls mu_msg_field_str */