[gmime: 4/7] Added more unit testing for GMimeReferences
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime: 4/7] Added more unit testing for GMimeReferences
- Date: Tue, 28 Mar 2017 23:47:03 +0000 (UTC)
commit 99cbfcbdd29d6c4588a703726bd61e97b37ad92a
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date: Tue Mar 28 12:58:16 2017 -0400
Added more unit testing for GMimeReferences
tests/test-mime.c | 24 ++++++++++++++++++------
1 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/tests/test-mime.c b/tests/test-mime.c
index c076f41..bc73ea2 100644
--- a/tests/test-mime.c
+++ b/tests/test-mime.c
@@ -744,7 +744,7 @@ static struct {
static void
test_references (GMimeParserOptions *options)
{
- GMimeReferences *refs;
+ GMimeReferences *refs, *copy;
guint i;
int j;
@@ -752,23 +752,35 @@ test_references (GMimeParserOptions *options)
testsuite_check ("references[%u]", i);
try {
if (!(refs = g_mime_references_parse (references[i].input)))
- throw (exception_new ("failed to parse references[%u]", i));
+ throw (exception_new ("failed to parse references"));
if (g_mime_references_length (refs) != references[i].count)
- throw (exception_new ("number of references does not match for
references[%u]", i));
+ throw (exception_new ("number of references does not match"));
for (j = 0; j < references[i].count; j++) {
const char *msgid = g_mime_references_get_message_id (refs, j);
if (strcmp (references[i].ids[j], msgid) != 0)
- throw (exception_new ("message ids do not match for
references[%u][%d]", i, j));
+ throw (exception_new ("message ids do not match for ids[%d]", j));
}
- g_mime_references_clear (refs);
+ copy = g_mime_references_copy (refs);
+ if (g_mime_references_length (copy) != g_mime_references_length (refs))
+ throw (exception_new ("number of copied references does not match"));
- if (g_mime_references_length (refs) != 0)
+ for (j = 0; j < references[i].count; j++) {
+ const char *msgid = g_mime_references_get_message_id (copy, j);
+
+ if (strcmp (references[i].ids[j], msgid) != 0)
+ throw (exception_new ("copied message ids do not match for ids[%d]",
j));
+ }
+
+ g_mime_references_clear (copy);
+
+ if (g_mime_references_length (copy) != 0)
throw (exception_new ("references were not cleared"));
+ g_mime_references_free (copy);
g_mime_references_free (refs);
testsuite_check_passed ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]