]> granicus.if.org Git - neomutt/commitdiff
Add tests for mutt_addrlist_copy
authorPietro Cerutti <gahr@gahr.ch>
Sat, 18 May 2019 17:07:30 +0000 (17:07 +0000)
committerRichard Russon <rich@flatcap.org>
Thu, 23 May 2019 10:57:10 +0000 (11:57 +0100)
test/address/mutt_addrlist_copy.c

index f5f1f423b3b288ee86cd60a5322ad29f649e5796..4a9b3875e8797a0cb64a9d3b37d8ca84419cf03a 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,33 @@ void test_mutt_addrlist_copy(void)
     mutt_addrlist_copy(&al, NULL, false);
     TEST_CHECK_(1, "mutt_addrlist_copy(&al, NULL, false)");
   }
+
+  {
+    struct AddressList src = TAILQ_HEAD_INITIALIZER(src);
+    struct AddressList dst = TAILQ_HEAD_INITIALIZER(dst);
+    mutt_addrlist_copy(&dst, &src, false);
+    TEST_CHECK(TAILQ_EMPTY(&src));
+    TEST_CHECK(TAILQ_EMPTY(&dst));
+  }
+
+  {
+    struct AddressList src = TAILQ_HEAD_INITIALIZER(src);
+    struct AddressList dst = TAILQ_HEAD_INITIALIZER(dst);
+    struct Address a1 = { .mailbox = "test@example.com" };
+    struct Address a2 = { .mailbox = "john@doe.org" };
+    struct Address a3 = { .mailbox = "the-who@stage.co.uk" };
+    mutt_addrlist_append(&src, &a1);
+    mutt_addrlist_append(&src, &a2);
+    mutt_addrlist_append(&src, &a3);
+    mutt_addrlist_copy(&dst, &src, false);
+    TEST_CHECK(!TAILQ_EMPTY(&src));
+    TEST_CHECK(!TAILQ_EMPTY(&dst));
+    struct Address *adst = TAILQ_FIRST(&dst);
+    TEST_CHECK_STR_EQ(a1.mailbox, adst->mailbox);
+    adst = TAILQ_NEXT(adst, entries);
+    TEST_CHECK_STR_EQ(a2.mailbox, adst->mailbox);
+    adst = TAILQ_NEXT(adst, entries);
+    TEST_CHECK_STR_EQ(a3.mailbox, adst->mailbox);
+    mutt_addrlist_free_all(&dst);
+  }
 }