]> granicus.if.org Git - neomutt/commitdiff
Add test for mutt_addrlist_append and mutt_addrlist_prepend
authorPietro Cerutti <gahr@gahr.ch>
Sat, 18 May 2019 16:51:50 +0000 (16:51 +0000)
committerRichard Russon <rich@flatcap.org>
Thu, 23 May 2019 10:57:10 +0000 (11:57 +0100)
test/address/mutt_addrlist_append.c
test/address/mutt_addrlist_prepend.c

index 586760796129c7f5d08e0c56d27ed83fb3697f14..814c62888912aaeecab0397b180a0d2a18052af8 100644 (file)
@@ -22,6 +22,7 @@
 
 #define TEST_NO_MAIN
 #include "acutest.h"
+#include "common.h"
 #include "config.h"
 #include "mutt/mutt.h"
 #include "address/lib.h"
@@ -41,4 +42,16 @@ void test_mutt_addrlist_append(void)
     mutt_addrlist_append(&al, NULL);
     TEST_CHECK_(1, "mutt_addrlist_append(&al, NULL)");
   }
+
+  {
+    struct Address a1 = { .mailbox = "test@example.com" };
+    struct Address a2 = { .mailbox = "john@doe.org" };
+    struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
+    mutt_addrlist_append(&al, &a1);
+    mutt_addrlist_append(&al, &a2);
+    struct Address *a = TAILQ_FIRST(&al);
+    TEST_CHECK_STR_EQ("test@example.com", a->mailbox);
+    a = TAILQ_NEXT(a, entries);
+    TEST_CHECK_STR_EQ("john@doe.org", a->mailbox);
+  }
 }
index 906c0dc5d21f7a59754725521914930413b3e4a0..986bffac38aa7dccf9511b34487ac02e233def43 100644 (file)
@@ -22,6 +22,7 @@
 
 #define TEST_NO_MAIN
 #include "acutest.h"
+#include "common.h"
 #include "config.h"
 #include "mutt/mutt.h"
 #include "address/lib.h"
@@ -41,4 +42,16 @@ void test_mutt_addrlist_prepend(void)
     mutt_addrlist_prepend(&al, NULL);
     TEST_CHECK_(1, "mutt_addrlist_prepend(&al, NULL)");
   }
+
+  {
+    struct Address a1 = { .mailbox = "test@example.com" };
+    struct Address a2 = { .mailbox = "john@doe.org" };
+    struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
+    mutt_addrlist_prepend(&al, &a1);
+    mutt_addrlist_prepend(&al, &a2);
+    struct Address *a = TAILQ_FIRST(&al);
+    TEST_CHECK_STR_EQ("john@doe.org", a->mailbox);
+    a = TAILQ_NEXT(a, entries);
+    TEST_CHECK_STR_EQ("test@example.com", a->mailbox);
+  }
 }