mirror of https://github.com/djcb/mu.git
* tests: cleanup test-mu-msg.c
This commit is contained in:
parent
b3760740f8
commit
dba062b97c
|
@ -1,6 +1,6 @@
|
|||
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
||||
/*
|
||||
** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
** Copyright (C) 2008-2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify it
|
||||
** under the terms of the GNU General Public License as published by the
|
||||
|
@ -33,6 +33,31 @@
|
|||
#include "mu-msg.h"
|
||||
#include "mu-str.h"
|
||||
|
||||
|
||||
static MuMsg*
|
||||
get_msg (const char *path)
|
||||
{
|
||||
GError *err;
|
||||
MuMsg *msg;
|
||||
|
||||
if (g_test_verbose ())
|
||||
g_print (">> %s\n", path);
|
||||
|
||||
err = NULL;
|
||||
msg = mu_msg_new_from_file (path, NULL, &err);
|
||||
|
||||
if (!msg) {
|
||||
g_printerr ("failed to load %s: %s\n",
|
||||
path, err ? err->message : "something went wrong");
|
||||
g_clear_error (&err);
|
||||
g_assert (0);
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static gboolean
|
||||
check_contact_01 (MuMsgContact *contact, int *idx)
|
||||
{
|
||||
|
@ -58,17 +83,13 @@ check_contact_01 (MuMsgContact *contact, int *idx)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_msg_01 (void)
|
||||
{
|
||||
MuMsg *msg;
|
||||
gint i;
|
||||
|
||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
||||
"/1220863042.12663_1.mindcrime!2,S",
|
||||
NULL, NULL);
|
||||
msg = get_msg (MU_TESTMAILDIR4 "/1220863042.12663_1.mindcrime!2,S");
|
||||
|
||||
g_assert_cmpstr (mu_msg_get_to(msg),
|
||||
==, "Donald Duck <gcc-help@gcc.gnu.org>");
|
||||
|
@ -132,9 +153,7 @@ test_mu_msg_02 (void)
|
|||
MuMsg *msg;
|
||||
int i;
|
||||
|
||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
||||
"/1220863087.12663_19.mindcrime!2,S",
|
||||
NULL, NULL);
|
||||
msg = get_msg (MU_TESTMAILDIR4 "/1220863087.12663_19.mindcrime!2,S");
|
||||
|
||||
g_assert_cmpstr (mu_msg_get_to(msg),
|
||||
==, "help-gnu-emacs@gnu.org");
|
||||
|
@ -168,9 +187,7 @@ test_mu_msg_03 (void)
|
|||
{
|
||||
MuMsg *msg;
|
||||
|
||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
||||
"/1283599333.1840_11.cthulhu!2,",
|
||||
NULL, NULL);
|
||||
msg = get_msg (MU_TESTMAILDIR4 "/1283599333.1840_11.cthulhu!2,");
|
||||
g_assert_cmpstr (mu_msg_get_to(msg),
|
||||
==, "Bilbo Baggins <bilbo@anotherexample.com>");
|
||||
g_assert_cmpstr (mu_msg_get_subject(msg),
|
||||
|
@ -196,8 +213,7 @@ test_mu_msg_04 (void)
|
|||
{
|
||||
MuMsg *msg;
|
||||
|
||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
||||
"/mail5", NULL, NULL);
|
||||
msg = get_msg (MU_TESTMAILDIR4 "/mail5");
|
||||
g_assert_cmpstr (mu_msg_get_to(msg),
|
||||
==, "George Custer <gac@example.com>");
|
||||
g_assert_cmpstr (mu_msg_get_subject(msg),
|
||||
|
@ -219,8 +235,7 @@ test_mu_msg_multimime (void)
|
|||
{
|
||||
MuMsg *msg;
|
||||
|
||||
msg = mu_msg_new_from_file
|
||||
(MU_TESTMAILDIR4 "/multimime!2,FS", NULL, NULL);
|
||||
msg = get_msg (MU_TESTMAILDIR4 "/multimime!2,FS");
|
||||
/* ie., are text parts properly concatenated? */
|
||||
g_assert_cmpstr (mu_msg_get_subject(msg),
|
||||
==, "multimime");
|
||||
|
@ -255,8 +270,7 @@ test_mu_msg_flags (void)
|
|||
MuMsg *msg;
|
||||
MuFlags flags;
|
||||
|
||||
g_assert ((msg = mu_msg_new_from_file
|
||||
(msgflags[u].path, NULL, NULL)));
|
||||
g_assert ((msg = get_msg (msgflags[u].path)));
|
||||
flags = mu_msg_get_flags (msg);
|
||||
|
||||
if (g_test_verbose())
|
||||
|
@ -278,9 +292,7 @@ test_mu_msg_umlaut (void)
|
|||
{
|
||||
MuMsg *msg;
|
||||
|
||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
||||
"/1305664394.2171_402.cthulhu!2,",
|
||||
NULL, NULL);
|
||||
msg = get_msg (MU_TESTMAILDIR4 "/1305664394.2171_402.cthulhu!2,");
|
||||
g_assert_cmpstr (mu_msg_get_to(msg),
|
||||
==, "Helmut Kröger <hk@testmu.xxx>");
|
||||
g_assert_cmpstr (mu_msg_get_subject(msg),
|
||||
|
@ -302,9 +314,7 @@ test_mu_msg_references (void)
|
|||
MuMsg *msg;
|
||||
const GSList *refs;
|
||||
|
||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
||||
"/1305664394.2171_402.cthulhu!2,",
|
||||
NULL, NULL);
|
||||
msg = get_msg (MU_TESTMAILDIR4 "/1305664394.2171_402.cthulhu!2,");
|
||||
refs = mu_msg_get_references(msg);
|
||||
|
||||
g_assert_cmpuint (g_slist_length ((GSList*)refs), ==, 4);
|
||||
|
@ -329,9 +339,7 @@ test_mu_msg_references_dups (void)
|
|||
MuMsg *msg;
|
||||
const GSList *refs;
|
||||
|
||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
||||
"/1252168370_3.14675.cthulhu!2,S",
|
||||
NULL, NULL);
|
||||
msg = get_msg (MU_TESTMAILDIR4 "/1252168370_3.14675.cthulhu!2,S");
|
||||
refs = mu_msg_get_references(msg);
|
||||
|
||||
/* make sure duplicate msg-ids are filtered out */
|
||||
|
@ -366,8 +374,7 @@ test_mu_msg_tags (void)
|
|||
MuMsg *msg;
|
||||
const GSList *tags;
|
||||
|
||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4 "/mail1",
|
||||
NULL, NULL);
|
||||
msg = get_msg (MU_TESTMAILDIR4 "/mail1");
|
||||
|
||||
g_assert_cmpstr (mu_msg_get_to(msg),
|
||||
==, "Julius Caesar <jc@example.com>");
|
||||
|
@ -398,8 +405,7 @@ test_mu_msg_comp_unix_programmer (void)
|
|||
MuMsg *msg;
|
||||
char *refs;
|
||||
|
||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
||||
"/181736.eml", NULL, NULL);
|
||||
msg = get_msg (MU_TESTMAILDIR4 "/181736.eml");
|
||||
g_assert_cmpstr (mu_msg_get_to(msg),
|
||||
==, NULL);
|
||||
g_assert_cmpstr (mu_msg_get_subject(msg),
|
||||
|
|
Loading…
Reference in New Issue