* tests: cleanup test-mu-msg.c
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
/* -*-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
|
** 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
|
** under the terms of the GNU General Public License as published by the
|
||||||
@ -33,6 +33,31 @@
|
|||||||
#include "mu-msg.h"
|
#include "mu-msg.h"
|
||||||
#include "mu-str.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
|
static gboolean
|
||||||
check_contact_01 (MuMsgContact *contact, int *idx)
|
check_contact_01 (MuMsgContact *contact, int *idx)
|
||||||
{
|
{
|
||||||
@ -58,17 +83,13 @@ check_contact_01 (MuMsgContact *contact, int *idx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_mu_msg_01 (void)
|
test_mu_msg_01 (void)
|
||||||
{
|
{
|
||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
msg = get_msg (MU_TESTMAILDIR4 "/1220863042.12663_1.mindcrime!2,S");
|
||||||
"/1220863042.12663_1.mindcrime!2,S",
|
|
||||||
NULL, NULL);
|
|
||||||
|
|
||||||
g_assert_cmpstr (mu_msg_get_to(msg),
|
g_assert_cmpstr (mu_msg_get_to(msg),
|
||||||
==, "Donald Duck <gcc-help@gcc.gnu.org>");
|
==, "Donald Duck <gcc-help@gcc.gnu.org>");
|
||||||
@ -132,9 +153,7 @@ test_mu_msg_02 (void)
|
|||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
msg = get_msg (MU_TESTMAILDIR4 "/1220863087.12663_19.mindcrime!2,S");
|
||||||
"/1220863087.12663_19.mindcrime!2,S",
|
|
||||||
NULL, NULL);
|
|
||||||
|
|
||||||
g_assert_cmpstr (mu_msg_get_to(msg),
|
g_assert_cmpstr (mu_msg_get_to(msg),
|
||||||
==, "help-gnu-emacs@gnu.org");
|
==, "help-gnu-emacs@gnu.org");
|
||||||
@ -168,9 +187,7 @@ test_mu_msg_03 (void)
|
|||||||
{
|
{
|
||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
|
|
||||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
msg = get_msg (MU_TESTMAILDIR4 "/1283599333.1840_11.cthulhu!2,");
|
||||||
"/1283599333.1840_11.cthulhu!2,",
|
|
||||||
NULL, NULL);
|
|
||||||
g_assert_cmpstr (mu_msg_get_to(msg),
|
g_assert_cmpstr (mu_msg_get_to(msg),
|
||||||
==, "Bilbo Baggins <bilbo@anotherexample.com>");
|
==, "Bilbo Baggins <bilbo@anotherexample.com>");
|
||||||
g_assert_cmpstr (mu_msg_get_subject(msg),
|
g_assert_cmpstr (mu_msg_get_subject(msg),
|
||||||
@ -196,8 +213,7 @@ test_mu_msg_04 (void)
|
|||||||
{
|
{
|
||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
|
|
||||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
msg = get_msg (MU_TESTMAILDIR4 "/mail5");
|
||||||
"/mail5", NULL, NULL);
|
|
||||||
g_assert_cmpstr (mu_msg_get_to(msg),
|
g_assert_cmpstr (mu_msg_get_to(msg),
|
||||||
==, "George Custer <gac@example.com>");
|
==, "George Custer <gac@example.com>");
|
||||||
g_assert_cmpstr (mu_msg_get_subject(msg),
|
g_assert_cmpstr (mu_msg_get_subject(msg),
|
||||||
@ -219,8 +235,7 @@ test_mu_msg_multimime (void)
|
|||||||
{
|
{
|
||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
|
|
||||||
msg = mu_msg_new_from_file
|
msg = get_msg (MU_TESTMAILDIR4 "/multimime!2,FS");
|
||||||
(MU_TESTMAILDIR4 "/multimime!2,FS", NULL, NULL);
|
|
||||||
/* ie., are text parts properly concatenated? */
|
/* ie., are text parts properly concatenated? */
|
||||||
g_assert_cmpstr (mu_msg_get_subject(msg),
|
g_assert_cmpstr (mu_msg_get_subject(msg),
|
||||||
==, "multimime");
|
==, "multimime");
|
||||||
@ -255,8 +270,7 @@ test_mu_msg_flags (void)
|
|||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
MuFlags flags;
|
MuFlags flags;
|
||||||
|
|
||||||
g_assert ((msg = mu_msg_new_from_file
|
g_assert ((msg = get_msg (msgflags[u].path)));
|
||||||
(msgflags[u].path, NULL, NULL)));
|
|
||||||
flags = mu_msg_get_flags (msg);
|
flags = mu_msg_get_flags (msg);
|
||||||
|
|
||||||
if (g_test_verbose())
|
if (g_test_verbose())
|
||||||
@ -278,9 +292,7 @@ test_mu_msg_umlaut (void)
|
|||||||
{
|
{
|
||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
|
|
||||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
msg = get_msg (MU_TESTMAILDIR4 "/1305664394.2171_402.cthulhu!2,");
|
||||||
"/1305664394.2171_402.cthulhu!2,",
|
|
||||||
NULL, NULL);
|
|
||||||
g_assert_cmpstr (mu_msg_get_to(msg),
|
g_assert_cmpstr (mu_msg_get_to(msg),
|
||||||
==, "Helmut Kröger <hk@testmu.xxx>");
|
==, "Helmut Kröger <hk@testmu.xxx>");
|
||||||
g_assert_cmpstr (mu_msg_get_subject(msg),
|
g_assert_cmpstr (mu_msg_get_subject(msg),
|
||||||
@ -302,9 +314,7 @@ test_mu_msg_references (void)
|
|||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
const GSList *refs;
|
const GSList *refs;
|
||||||
|
|
||||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
msg = get_msg (MU_TESTMAILDIR4 "/1305664394.2171_402.cthulhu!2,");
|
||||||
"/1305664394.2171_402.cthulhu!2,",
|
|
||||||
NULL, NULL);
|
|
||||||
refs = mu_msg_get_references(msg);
|
refs = mu_msg_get_references(msg);
|
||||||
|
|
||||||
g_assert_cmpuint (g_slist_length ((GSList*)refs), ==, 4);
|
g_assert_cmpuint (g_slist_length ((GSList*)refs), ==, 4);
|
||||||
@ -329,9 +339,7 @@ test_mu_msg_references_dups (void)
|
|||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
const GSList *refs;
|
const GSList *refs;
|
||||||
|
|
||||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
msg = get_msg (MU_TESTMAILDIR4 "/1252168370_3.14675.cthulhu!2,S");
|
||||||
"/1252168370_3.14675.cthulhu!2,S",
|
|
||||||
NULL, NULL);
|
|
||||||
refs = mu_msg_get_references(msg);
|
refs = mu_msg_get_references(msg);
|
||||||
|
|
||||||
/* make sure duplicate msg-ids are filtered out */
|
/* make sure duplicate msg-ids are filtered out */
|
||||||
@ -366,8 +374,7 @@ test_mu_msg_tags (void)
|
|||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
const GSList *tags;
|
const GSList *tags;
|
||||||
|
|
||||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4 "/mail1",
|
msg = get_msg (MU_TESTMAILDIR4 "/mail1");
|
||||||
NULL, NULL);
|
|
||||||
|
|
||||||
g_assert_cmpstr (mu_msg_get_to(msg),
|
g_assert_cmpstr (mu_msg_get_to(msg),
|
||||||
==, "Julius Caesar <jc@example.com>");
|
==, "Julius Caesar <jc@example.com>");
|
||||||
@ -398,8 +405,7 @@ test_mu_msg_comp_unix_programmer (void)
|
|||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
char *refs;
|
char *refs;
|
||||||
|
|
||||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
msg = get_msg (MU_TESTMAILDIR4 "/181736.eml");
|
||||||
"/181736.eml", NULL, NULL);
|
|
||||||
g_assert_cmpstr (mu_msg_get_to(msg),
|
g_assert_cmpstr (mu_msg_get_to(msg),
|
||||||
==, NULL);
|
==, NULL);
|
||||||
g_assert_cmpstr (mu_msg_get_subject(msg),
|
g_assert_cmpstr (mu_msg_get_subject(msg),
|
||||||
|
|||||||
Reference in New Issue
Block a user