]> granicus.if.org Git - neomutt/commitdiff
test: update basic address tests
authorRichard Russon <rich@flatcap.org>
Fri, 17 May 2019 21:37:08 +0000 (22:37 +0100)
committerRichard Russon <rich@flatcap.org>
Thu, 23 May 2019 10:57:10 +0000 (11:57 +0100)
28 files changed:
address/address.c
test/Makefile.autosetup
test/address/mutt_addr_cmp.c
test/address/mutt_addr_copy.c
test/address/mutt_addr_for_display.c
test/address/mutt_addr_free.c
test/address/mutt_addr_new.c
test/address/mutt_addr_write.c
test/address/mutt_addr_write_single.c [deleted file]
test/address/mutt_addrlist_append.c [new file with mode: 0644]
test/address/mutt_addrlist_copy.c [new file with mode: 0644]
test/address/mutt_addrlist_dedupe.c
test/address/mutt_addrlist_equal.c
test/address/mutt_addrlist_free.c [moved from test/address/mutt_addr_copy_list.c with 77% similarity]
test/address/mutt_addrlist_free_all.c [new file with mode: 0644]
test/address/mutt_addrlist_free_one.c [new file with mode: 0644]
test/address/mutt_addrlist_has_recips.c [moved from test/address/mutt_addr_has_recips.c with 86% similarity]
test/address/mutt_addrlist_new.c [new file with mode: 0644]
test/address/mutt_addrlist_parse.c
test/address/mutt_addrlist_parse2.c
test/address/mutt_addrlist_prepend.c [new file with mode: 0644]
test/address/mutt_addrlist_qualify.c
test/address/mutt_addrlist_remove_xrefs.c
test/address/mutt_addrlist_search.c [moved from test/address/mutt_addr_search.c with 93% similarity]
test/address/mutt_addrlist_to_intl.c
test/address/mutt_addrlist_to_local.c
test/address/mutt_addrlist_write.c [new file with mode: 0644]
test/main.c

index e64113806f99f54ca18d73f4868b04dc14181510..1d47f7b030e554c3ac2526c322583e329469852d 100644 (file)
@@ -1356,6 +1356,9 @@ struct AddressList *mutt_addrlist_new(void)
  */
 void mutt_addrlist_free_one(struct AddressList *al, struct Address *a)
 {
+  if (!al || !a)
+    return;
+
   TAILQ_REMOVE(al, a, entries);
   mutt_addr_free(&a);
 }
index fc05a58fb4637ead0b75f81e3e4393637670a47c..87b2e83269bb310950b4079d20db7b268a2951aa 100644 (file)
@@ -1,24 +1,30 @@
 ADDRESS_OBJS   = test/address/mutt_addr_cat.o \
                  test/address/mutt_addr_cmp.o \
                  test/address/mutt_addr_copy.o \
-                 test/address/mutt_addr_copy_list.o \
                  test/address/mutt_addr_for_display.o \
                  test/address/mutt_addr_free.o \
-                 test/address/mutt_addr_has_recips.o \
+                 test/address/mutt_addr_new.o \
+                 test/address/mutt_addr_valid_msgid.o \
+                 test/address/mutt_addr_write.o \
+                 test/address/mutt_addrlist_append.o \
+                 test/address/mutt_addrlist_copy.o \
                  test/address/mutt_addrlist_dedupe.o \
                  test/address/mutt_addrlist_equal.o \
-                 test/address/mutt_addrlist_parse2.o \
+                 test/address/mutt_addrlist_free.o \
+                 test/address/mutt_addrlist_free_all.o \
+                 test/address/mutt_addrlist_free_one.o \
+                 test/address/mutt_addrlist_has_recips.o \
+                 test/address/mutt_addrlist_new.o \
                  test/address/mutt_addrlist_parse.o \
+                 test/address/mutt_addrlist_parse2.o \
+                 test/address/mutt_addrlist_prepend.o \
                  test/address/mutt_addrlist_qualify.o \
                  test/address/mutt_addrlist_remove.o \
                  test/address/mutt_addrlist_remove_xrefs.o \
+                 test/address/mutt_addrlist_search.o \
                  test/address/mutt_addrlist_to_intl.o \
                  test/address/mutt_addrlist_to_local.o \
-                 test/address/mutt_addr_new.o \
-                 test/address/mutt_addr_search.o \
-                 test/address/mutt_addr_valid_msgid.o \
-                 test/address/mutt_addr_write.o \
-                 test/address/mutt_addr_write_single.o
+                 test/address/mutt_addrlist_write.o
 
 ATTACH_OBJS    = test/attach/mutt_actx_add_fp.o \
                  test/attach/mutt_actx_free_entries.o \
index b43cb2b50f73e6a700116e6bfa02a99943a090cd..4aa2a2b6eef9ee292651cebbf6506e5f37e6dec3 100644 (file)
@@ -28,7 +28,7 @@
 
 void test_mutt_addr_cmp(void)
 {
-  // bool mutt_addr_cmp(struct Address *a, struct Address *b);
+  // bool mutt_addr_cmp(const struct Address *a, const struct Address *b);
 
   {
     struct Address addr = { 0 };
index 12a272f4088fdb42c9dbbc93ea135449ba40519a..e71fbf75343a3cfbdea2af9df410f894b5f69859 100644 (file)
@@ -28,7 +28,7 @@
 
 void test_mutt_addr_copy(void)
 {
-  // struct Address *mutt_addr_copy(struct Address *addr);
+  // struct Address *mutt_addr_copy(const struct Address *addr);
 
   {
     TEST_CHECK(!mutt_addr_copy(NULL));
index 45893c28004ff64ad164b7357810a4ddfa45e3de..98eb1fc0dcd3f9c0636da5999267f994447fccab 100644 (file)
@@ -29,7 +29,7 @@
 
 void test_mutt_addr_for_display(void)
 {
-  // const char * mutt_addr_for_display(struct Address *a);
+  // const char *mutt_addr_for_display(const struct Address *a);
 
   {
     TEST_CHECK(!mutt_addr_for_display(NULL));
index cb33e33463a329ad9e33832fae5aecf211bd9fa5..9f44fcdf83136af6f06e9e5168f60c6f3b24d4e7 100644 (file)
@@ -28,7 +28,7 @@
 
 void test_mutt_addr_free(void)
 {
-  // void mutt_addr_free(struct Address **p);
+  // void mutt_addr_free(struct Address **a);
 
   {
     mutt_addr_free(NULL);
index bd96ae5c46272b268a60917fd85ef3adce93b336..ddc01d7798e22bc1749442cd00fa883c2e82ed0c 100644 (file)
 void test_mutt_addr_new(void)
 {
   // struct Address *mutt_addr_new(void);
+
+  {
+    struct Address *a = NULL;
+
+    TEST_CHECK((a = mutt_addr_new()) != NULL);
+
+    mutt_addr_free(&a);
+  }
 }
index e6d0bcb63736d1790216ee206c797b530e857760..b75181acae66b7d2174d5a62c4e90e3947b9ba58 100644 (file)
@@ -25,6 +25,7 @@
 #include "config.h"
 #include "mutt/mutt.h"
 #include "address/lib.h"
+#include "common.h"
 
 void test_mutt_addr_write(void)
 {
@@ -32,11 +33,34 @@ void test_mutt_addr_write(void)
 
   {
     struct Address addr = { 0 };
-    TEST_CHECK(mutt_addr_write(NULL, 32, &addr, false) == 0);
+    mutt_addr_write(NULL, 32, &addr, false);
+    TEST_CHECK_(1, "mutt_addr_write(NULL, 32, &addr, false)");
   }
 
   {
     char buf[32] = { 0 };
-    TEST_CHECK(mutt_addr_write(buf, sizeof(buf), NULL, false) == 0);
+    mutt_addr_write(buf, sizeof(buf), NULL, false);
+    TEST_CHECK_(1, "mutt_addr_write(buf, sizeof(buf), NULL, false)");
+  }
+
+  { /* integration */
+    char buf[256] = { 0 };
+    char per[64] = "bobby bob";
+    char mbx[64] = "bob@bobsdomain";
+
+    struct Address addr = {
+      .personal = per,
+      .mailbox = mbx,
+      .group = 0,
+      .is_intl = 0,
+      .intl_checked = 0,
+    };
+
+    size_t len = mutt_addr_write(buf, sizeof(buf), &addr, false);
+
+    const char *expected = "bobby bob <bob@bobsdomain>";
+
+    TEST_CHECK_STR_EQ(expected, buf);
+    TEST_CHECK(len == strlen(expected));
   }
 }
diff --git a/test/address/mutt_addr_write_single.c b/test/address/mutt_addr_write_single.c
deleted file mode 100644 (file)
index 126df68..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * @file
- * Test code for mutt_addr_write_single()
- *
- * @authors
- * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
- *
- * @copyright
- * 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 Free Software
- * Foundation, either version 2 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#define TEST_NO_MAIN
-#include "acutest.h"
-#include "config.h"
-#include "mutt/mutt.h"
-#include "address/lib.h"
-#include "common.h"
-
-void test_mutt_addr_write_single(void)
-{
-  // void mutt_addr_write_single(char *buf, size_t buflen, struct Address *addr, bool display);
-
-  {
-    struct Address addr = { 0 };
-    mutt_addr_write(NULL, 32, &addr, false);
-    TEST_CHECK_(1, "mutt_addr_write_single(NULL, 32, &addr, false)");
-  }
-
-  {
-    char buf[32] = { 0 };
-    mutt_addr_write(buf, sizeof(buf), NULL, false);
-    TEST_CHECK_(1, "mutt_addr_write_single(buf, sizeof(buf), NULL, false)");
-  }
-
-  { /* integration */
-    char buf[256] = { 0 };
-    char per[64] = "bobby bob";
-    char mbx[64] = "bob@bobsdomain";
-
-    struct Address addr = {
-      .personal = per,
-      .mailbox = mbx,
-      .group = 0,
-      .is_intl = 0,
-      .intl_checked = 0,
-    };
-
-    size_t len = mutt_addr_write(buf, sizeof(buf), &addr, false);
-
-    const char *expected = "bobby bob <bob@bobsdomain>";
-
-    TEST_CHECK_STR_EQ(expected, buf);
-    TEST_CHECK(len == strlen(expected));
-  }
-}
diff --git a/test/address/mutt_addrlist_append.c b/test/address/mutt_addrlist_append.c
new file mode 100644 (file)
index 0000000..5867607
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+ * @file
+ * Test code for mutt_addrlist_append()
+ *
+ * @authors
+ * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * 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 Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define TEST_NO_MAIN
+#include "acutest.h"
+#include "config.h"
+#include "mutt/mutt.h"
+#include "address/lib.h"
+
+void test_mutt_addrlist_append(void)
+{
+  // void mutt_addrlist_append(struct AddressList *al, struct Address *a);
+
+  {
+    struct Address a = { 0 };
+    mutt_addrlist_append(NULL, &a);
+    TEST_CHECK_(1, "mutt_addrlist_append(NULL, &a)");
+  }
+
+  {
+    struct AddressList al = { 0 };
+    mutt_addrlist_append(&al, NULL);
+    TEST_CHECK_(1, "mutt_addrlist_append(&al, NULL)");
+  }
+}
diff --git a/test/address/mutt_addrlist_copy.c b/test/address/mutt_addrlist_copy.c
new file mode 100644 (file)
index 0000000..f5f1f42
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+ * @file
+ * Test code for mutt_addrlist_copy()
+ *
+ * @authors
+ * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * 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 Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define TEST_NO_MAIN
+#include "acutest.h"
+#include "config.h"
+#include "mutt/mutt.h"
+#include "address/lib.h"
+
+void test_mutt_addrlist_copy(void)
+{
+  // void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune);
+
+  {
+    struct AddressList al = { 0 };
+    mutt_addrlist_copy(NULL, &al, false);
+    TEST_CHECK_(1, "mutt_addrlist_copy(NULL, &al, false)");
+  }
+
+  {
+    struct AddressList al = { 0 };
+    mutt_addrlist_copy(&al, NULL, false);
+    TEST_CHECK_(1, "mutt_addrlist_copy(&al, NULL, false)");
+  }
+}
index 4c945634d63a35b9d9bd34cfd91b438dcd3da855..153e31043d3f9f07810bc7b3ed367bae480b9e08 100644 (file)
@@ -32,6 +32,6 @@ void test_mutt_addrlist_dedupe(void)
 
   {
     mutt_addrlist_dedupe(NULL);
-    TEST_CHECK(true); // no crash
+    TEST_CHECK_(1, "mutt_addrlist_dedupe(NULL)");
   }
 }
index 0ab0d142754d3390ca992f701811c005ffa69bd9..583b7ac7f62a90f351fbb1bde11ac7567d6cc201 100644 (file)
@@ -28,7 +28,7 @@
 
 void test_mutt_addrlist_equal(void)
 {
-  // bool mutt_addrlist_equal(const struct AddressList *a, const struct AddressList *b);
+  // bool mutt_addrlist_equal(const struct AddressList *ala, const struct AddressList *alb);
 
   {
     struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
@@ -39,4 +39,8 @@ void test_mutt_addrlist_equal(void)
     struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
     TEST_CHECK(!mutt_addrlist_equal(&al, NULL));
   }
+
+  {
+    TEST_CHECK(mutt_addrlist_equal(NULL, NULL));
+  }
 }
similarity index 77%
rename from test/address/mutt_addr_copy_list.c
rename to test/address/mutt_addrlist_free.c
index 907d41b749ca2dea6d3c8fee4a6b94087824ae11..84e12a888705d034f204fe2766bce016cbb204bc 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * @file
- * Test code for mutt_addr_copy_list()
+ * Test code for mutt_addrlist_free()
  *
  * @authors
  * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
 #include "mutt/mutt.h"
 #include "address/lib.h"
 
-void test_mutt_addr_copy_list(void)
+void test_mutt_addrlist_free(void)
 {
-  // void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune);
+  // void mutt_addrlist_free(struct AddressList **al);
 
   {
-    mutt_addrlist_copy(NULL, NULL, false);
-    TEST_CHECK(true); // no crash
+    mutt_addrlist_free(NULL);
+    TEST_CHECK_(1, "mutt_addrlist_free(NULL)");
   }
 }
diff --git a/test/address/mutt_addrlist_free_all.c b/test/address/mutt_addrlist_free_all.c
new file mode 100644 (file)
index 0000000..0b3358d
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * @file
+ * Test code for mutt_addrlist_free_all()
+ *
+ * @authors
+ * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * 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 Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define TEST_NO_MAIN
+#include "acutest.h"
+#include "config.h"
+#include "mutt/mutt.h"
+#include "address/lib.h"
+
+void test_mutt_addrlist_free_all(void)
+{
+  // void mutt_addrlist_free_all(struct AddressList *al);
+
+  {
+    mutt_addrlist_free_all(NULL);
+    TEST_CHECK_(1, "mutt_addrlist_free_all(NULL)");
+  }
+}
diff --git a/test/address/mutt_addrlist_free_one.c b/test/address/mutt_addrlist_free_one.c
new file mode 100644 (file)
index 0000000..d95aa4a
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+ * @file
+ * Test code for mutt_addrlist_free_one()
+ *
+ * @authors
+ * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * 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 Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define TEST_NO_MAIN
+#include "acutest.h"
+#include "config.h"
+#include "mutt/mutt.h"
+#include "address/lib.h"
+
+void test_mutt_addrlist_free_one(void)
+{
+  // void mutt_addrlist_free_one(struct AddressList *al, struct Address *a);
+
+  {
+    struct Address a = { 0 };
+    mutt_addrlist_free_one(NULL, &a);
+    TEST_CHECK_(1, "mutt_addrlist_free_one(NULL, &a)");
+  }
+
+  {
+    struct AddressList al = { 0 };
+    mutt_addrlist_free_one(&al, NULL);
+    TEST_CHECK_(1, "mutt_addrlist_free_one(&al, NULL)");
+  }
+}
similarity index 86%
rename from test/address/mutt_addr_has_recips.c
rename to test/address/mutt_addrlist_has_recips.c
index 92c1b5ec5abc058098765a88319ac4d262f7e840..ebe75e1f223a4a322a8011c2d5b0ad31c03f967d 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * @file
- * Test code for mutt_addr_has_recips()
+ * Test code for mutt_addrlist_has_recips()
  *
  * @authors
  * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
@@ -26,9 +26,9 @@
 #include "mutt/mutt.h"
 #include "address/lib.h"
 
-void test_mutt_addr_has_recips(void)
+void test_mutt_addrlist_has_recips(void)
 {
-  // int mutt_addrlist_has_recips(const struct AddressList *a);
+  // int mutt_addrlist_has_recips(const struct AddressList *al);
 
   {
     TEST_CHECK(mutt_addrlist_has_recips(NULL) == 0);
diff --git a/test/address/mutt_addrlist_new.c b/test/address/mutt_addrlist_new.c
new file mode 100644 (file)
index 0000000..7031407
--- /dev/null
@@ -0,0 +1,40 @@
+/**
+ * @file
+ * Test code for mutt_addrlist_new()
+ *
+ * @authors
+ * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * 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 Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define TEST_NO_MAIN
+#include "acutest.h"
+#include "config.h"
+#include "mutt/mutt.h"
+#include "address/lib.h"
+
+void test_mutt_addrlist_new(void)
+{
+  // struct AddressList *mutt_addrlist_new(void);
+
+  {
+    struct AddressList *al = NULL;
+
+    TEST_CHECK((al = mutt_addrlist_new()) != NULL);
+
+    mutt_addrlist_free(&al);
+  }
+}
index 609b8f57c4ed6378b778207b74f2fd4d66407d6c..77f93eedd223d4cba5120ee4dda6808704ec8601 100644 (file)
@@ -28,7 +28,7 @@
 
 void test_mutt_addrlist_parse(void)
 {
-  // void mutt_addrlist_parse(struct AddressList *top, const char *s);
+  // int mutt_addrlist_parse(struct AddressList *al, const char *s);
 
   {
     struct AddressList alist = TAILQ_HEAD_INITIALIZER(alist);
index 2a2b1d4e46b7f1037b26cbd68b2b325bd15f2f38..73ae99bbe9219779ef44659763645eec18d569b0 100644 (file)
 
 void test_mutt_addrlist_parse2(void)
 {
-  // struct Address *mutt_addrlist_parse2(struct Address *p, const char *s);
+  // int mutt_addrlist_parse2(struct AddressList *al, const char *s);
+
   {
     struct AddressList alist = TAILQ_HEAD_INITIALIZER(alist);
-    mutt_addrlist_parse(&alist, "apple");
+    mutt_addrlist_parse2(&alist, "apple");
     TEST_CHECK(TAILQ_FIRST(&alist) != NULL);
     mutt_addrlist_free_all(&alist);
   }
 
   {
     struct AddressList alist = TAILQ_HEAD_INITIALIZER(alist);
-    mutt_addrlist_parse(&alist, NULL);
+    mutt_addrlist_parse2(&alist, NULL);
     TEST_CHECK(TAILQ_FIRST(&alist) == NULL);
   }
 
diff --git a/test/address/mutt_addrlist_prepend.c b/test/address/mutt_addrlist_prepend.c
new file mode 100644 (file)
index 0000000..906c0dc
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+ * @file
+ * Test code for mutt_addrlist_prepend()
+ *
+ * @authors
+ * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * 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 Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define TEST_NO_MAIN
+#include "acutest.h"
+#include "config.h"
+#include "mutt/mutt.h"
+#include "address/lib.h"
+
+void test_mutt_addrlist_prepend(void)
+{
+  // void mutt_addrlist_prepend(struct AddressList *al, struct Address *a);
+
+  {
+    struct Address a = { 0 };
+    mutt_addrlist_prepend(NULL, &a);
+    TEST_CHECK_(1, "mutt_addrlist_prepend(NULL, &a)");
+  }
+
+  {
+    struct AddressList al = { 0 };
+    mutt_addrlist_prepend(&al, NULL);
+    TEST_CHECK_(1, "mutt_addrlist_prepend(&al, NULL)");
+  }
+}
index 9cd9b86152c4822e1987034627612cbd1aab52eb..8dcdb90a6e90ff465d36c83161fdf0e0c9da32ef 100644 (file)
@@ -28,7 +28,7 @@
 
 void test_mutt_addrlist_qualify(void)
 {
-  // void mutt_addrlist_qualify(struct Address *addr, const char *host);
+  // void mutt_addrlist_qualify(struct AddressList *al, const char *host);
 
   {
     mutt_addrlist_qualify(NULL, "example.com");
index 58cac88e42fbf82f022d18657206a9fce024cd70..b3297610299934b7f1f69b209cf2b5c1226235f4 100644 (file)
 
 void test_mutt_addrlist_remove_xrefs(void)
 {
-  // TODO - check when either argument is NULL
+  // void mutt_addrlist_remove_xrefs(const struct AddressList *a, struct AddressList *b);
+
+  {
+    struct AddressList al = { 0 };
+    mutt_addrlist_remove_xrefs(NULL, &al);
+    TEST_CHECK_(1, "mutt_addrlist_remove_xrefs(NULL, &al)");
+  }
+
+  {
+    struct AddressList al = { 0 };
+    mutt_addrlist_remove_xrefs(&al, NULL);
+    TEST_CHECK_(1, "mutt_addrlist_remove_xrefs(&al, NULL)");
+  }
 }
similarity index 93%
rename from test/address/mutt_addr_search.c
rename to test/address/mutt_addrlist_search.c
index 7d69dad3aafef52d50bfe9d9473f5e84fd30c2eb..b547d4889521972e1431a48c17eb5ba57613a91e 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * @file
- * Test code for mutt_addr_search()
+ * Test code for mutt_addrlist_search()
  *
  * @authors
  * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
@@ -26,7 +26,7 @@
 #include "mutt/mutt.h"
 #include "address/lib.h"
 
-void test_mutt_addr_search(void)
+void test_mutt_addrlist_search(void)
 {
   // bool mutt_addrlist_search(const struct Address *needle, const struct AddressList *haystack);
 
index 82cab35a1cdf7fcf53751cd9e71b44c3d26c0e18..15d7f7546c26dda765807c518ceb18b57de71ec9 100644 (file)
@@ -28,7 +28,7 @@
 
 void test_mutt_addrlist_to_intl(void)
 {
-  // int mutt_addrlist_to_intl(struct AddressList *a, char **err);
+  // int mutt_addrlist_to_intl(struct AddressList *al, char **err);
 
   {
     char *err = NULL;
index e884e4ce9516c8c6353b80d1fa1e61416926e8a3..9488f50862a100598e3c215ae13a6c4a98e6f0ad 100644 (file)
@@ -28,7 +28,7 @@
 
 void test_mutt_addrlist_to_local(void)
 {
-  // int mutt_addrlist_to_local(struct AddressList *a);
+  // int mutt_addrlist_to_local(struct AddressList *al);
 
   {
     TEST_CHECK(mutt_addrlist_to_local(NULL) == 0);
diff --git a/test/address/mutt_addrlist_write.c b/test/address/mutt_addrlist_write.c
new file mode 100644 (file)
index 0000000..3c38e90
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+ * @file
+ * Test code for mutt_addrlist_write()
+ *
+ * @authors
+ * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * 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 Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define TEST_NO_MAIN
+#include "acutest.h"
+#include "config.h"
+#include "mutt/mutt.h"
+#include "address/lib.h"
+
+void test_mutt_addrlist_write(void)
+{
+  // size_t mutt_addrlist_write(char *buf, size_t buflen, const struct AddressList *al, bool display);
+
+  {
+    struct AddressList al = { 0 };
+    mutt_addrlist_write(NULL, 32, &al, false);
+    TEST_CHECK_(1, "mutt_addrlist_write(NULL, 32, &al, false)");
+  }
+
+  {
+    char buf[32] = { 0 };
+    mutt_addrlist_write(buf, sizeof(buf), NULL, false);
+    TEST_CHECK_(1, "mutt_addrlist_write(buf, sizeof(buf), NULL, false)");
+  }
+}
index 80cb25945b4b2530a7faf70729456e6f565ae577..06fe780f77bea47975f8e227ff34381b8302dc42 100644 (file)
   NEOMUTT_TEST_ITEM(test_mutt_addr_cat)                                        \
   NEOMUTT_TEST_ITEM(test_mutt_addr_cmp)                                        \
   NEOMUTT_TEST_ITEM(test_mutt_addr_copy)                                       \
-  NEOMUTT_TEST_ITEM(test_mutt_addr_copy_list)                                  \
   NEOMUTT_TEST_ITEM(test_mutt_addr_for_display)                                \
   NEOMUTT_TEST_ITEM(test_mutt_addr_free)                                       \
-  NEOMUTT_TEST_ITEM(test_mutt_addr_has_recips)                                 \
   NEOMUTT_TEST_ITEM(test_mutt_addr_new)                                        \
-  NEOMUTT_TEST_ITEM(test_mutt_addr_search)                                     \
   NEOMUTT_TEST_ITEM(test_mutt_addr_valid_msgid)                                \
   NEOMUTT_TEST_ITEM(test_mutt_addr_write)                                      \
-  NEOMUTT_TEST_ITEM(test_mutt_addr_write_single)                               \
+  NEOMUTT_TEST_ITEM(test_mutt_addrlist_append)                                 \
+  NEOMUTT_TEST_ITEM(test_mutt_addrlist_copy)                                   \
+  NEOMUTT_TEST_ITEM(test_mutt_addrlist_dedupe)                                 \
   NEOMUTT_TEST_ITEM(test_mutt_addrlist_equal)                                  \
+  NEOMUTT_TEST_ITEM(test_mutt_addrlist_free)                                   \
+  NEOMUTT_TEST_ITEM(test_mutt_addrlist_free_all)                               \
+  NEOMUTT_TEST_ITEM(test_mutt_addrlist_free_one)                               \
+  NEOMUTT_TEST_ITEM(test_mutt_addrlist_has_recips)                             \
+  NEOMUTT_TEST_ITEM(test_mutt_addrlist_new)                                    \
   NEOMUTT_TEST_ITEM(test_mutt_addrlist_parse)                                  \
   NEOMUTT_TEST_ITEM(test_mutt_addrlist_parse2)                                 \
+  NEOMUTT_TEST_ITEM(test_mutt_addrlist_prepend)                                \
   NEOMUTT_TEST_ITEM(test_mutt_addrlist_qualify)                                \
   NEOMUTT_TEST_ITEM(test_mutt_addrlist_remove)                                 \
   NEOMUTT_TEST_ITEM(test_mutt_addrlist_remove_xrefs)                           \
+  NEOMUTT_TEST_ITEM(test_mutt_addrlist_search)                                 \
   NEOMUTT_TEST_ITEM(test_mutt_addrlist_to_intl)                                \
   NEOMUTT_TEST_ITEM(test_mutt_addrlist_to_local)                               \
+  NEOMUTT_TEST_ITEM(test_mutt_addrlist_write)                                  \
   NEOMUTT_TEST_ITEM(test_mutt_actx_add_attach)                                 \
   NEOMUTT_TEST_ITEM(test_mutt_actx_add_body)                                   \
   NEOMUTT_TEST_ITEM(test_mutt_actx_add_fp)                                     \