From a9161d1cd50440138308dd9fc00244946485ef37 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Thu, 16 Jun 2011 00:49:30 +0300 Subject: [PATCH] * add unit tests for reading tags --- src/tests/test-mu-msg.c | 35 +++++++++++++++++++++++++++++++- src/tests/testdir2/bar/cur/mail1 | 1 + 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/tests/test-mu-msg.c b/src/tests/test-mu-msg.c index 9664b077..cda44f4b 100644 --- a/src/tests/test-mu-msg.c +++ b/src/tests/test-mu-msg.c @@ -241,6 +241,37 @@ test_mu_msg_05 (void) } +static void +test_mu_msg_tags (void) +{ + MuMsg *msg; + const GSList *tags; + + msg = mu_msg_new_from_file (MU_TESTMAILDIR2 + "/bar/cur/mail1", + NULL, NULL); + + g_assert_cmpstr (mu_msg_get_to(msg), + ==, "Julius Caesar "); + g_assert_cmpstr (mu_msg_get_subject(msg), + ==, "Fere libenter homines id quod volunt credunt"); + g_assert_cmpstr (mu_msg_get_from(msg), + ==, "John Milton "); + g_assert_cmpuint (mu_msg_get_prio(msg), /* 'low' */ + ==, MU_MSG_PRIO_HIGH); + g_assert_cmpuint (mu_msg_get_date(msg), + ==, 1217530645); + + tags = mu_msg_get_tags (msg); + 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); +} + + + /* static gboolean */ /* ignore_error (const char* log_domain, GLogLevelFlags log_level, const gchar* msg, */ /* gpointer user_data) */ @@ -266,7 +297,9 @@ main (int argc, char *argv[]) test_mu_msg_04); g_test_add_func ("/mu-msg/mu-msg-05", test_mu_msg_05); - + g_test_add_func ("/mu-msg/mu-msg-tags", + test_mu_msg_tags); + g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION, (GLogFunc)black_hole, NULL); diff --git a/src/tests/testdir2/bar/cur/mail1 b/src/tests/testdir2/bar/cur/mail1 index b93c62d5..801179a8 100644 --- a/src/tests/testdir2/bar/cur/mail1 +++ b/src/tests/testdir2/bar/cur/mail1 @@ -4,6 +4,7 @@ Subject: Fere libenter homines id quod volunt credunt To: "Julius Caesar" Message-id: <3BE9E6535E3029448670913581E7A1A20D852173@emss35m06.us.lmco.com> MIME-version: 1.0 +x-label: paradise,lost Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Precedence: high