]> granicus.if.org Git - neomutt/commitdiff
Add (basic) tests for mutt_addrlist_to_(intl|local)
authorPietro Cerutti <gahr@gahr.ch>
Wed, 22 May 2019 09:00:42 +0000 (09:00 +0000)
committerRichard Russon <rich@flatcap.org>
Thu, 23 May 2019 10:57:10 +0000 (11:57 +0100)
test/address/mutt_addrlist_to_intl.c
test/address/mutt_addrlist_to_local.c

index d31649881731dea56de0616cccdeaa42ca0ad6ba..09b1b687a45dfbe94537df7694b47ba988d49013 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "mutt/mutt.h"
 #include "address/lib.h"
+#include "common.h"
 
 void test_mutt_addrlist_to_intl(void)
 {
@@ -40,4 +41,39 @@ void test_mutt_addrlist_to_intl(void)
     struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
     TEST_CHECK(mutt_addrlist_to_intl(&al, NULL) == 0);
   }
+
+  {
+    struct {
+      const char *local;
+      const char *intl;
+    } local2intl[] = {
+        {
+          .local = "test@äöüss.com",
+          .intl  = "test@xn--ss-uia6e4a.com"
+        },
+        {
+          .local = "test@nixieröhre.nixieclock-tube.com",
+          .intl  = "test@xn--nixierhre-57a.nixieclock-tube.com"
+        },
+        {
+          .local = "test@வலைப்பூ.com",
+          .intl  = "test@xn--xlcawl2e7azb.com"
+        }
+    };
+
+    C_Charset = "utf-8";
+    C_IdnEncode = true;
+    C_IdnDecode = true;
+    for (size_t i = 0; i < mutt_array_size(local2intl); ++i)
+    {
+      struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
+      mutt_addrlist_append(&al, mutt_addr_create(NULL, local2intl[i].local));
+      mutt_addrlist_to_intl(&al, NULL);
+      struct Address *a = TAILQ_FIRST(&al);
+      TEST_CHECK_STR_EQ(local2intl[i].intl, a->mailbox);
+      mutt_addrlist_to_local(&al);
+      TEST_CHECK_STR_EQ(local2intl[i].local, a->mailbox);
+      mutt_addrlist_clear(&al);
+    }
+  }
 }
index e18d2715e2cb08a3230d805aad137f4699c792cd..0f871b46efd0b476e803691b78b9b27fe79577eb 100644 (file)
@@ -34,4 +34,10 @@ void test_mutt_addrlist_to_local(void)
   {
     TEST_CHECK(mutt_addrlist_to_local(NULL) == 0);
   }
+
+  {
+    // Back and forth tests (to_intl <-> to_local) are done in
+    // test_mutt_addrlist_to_intl
+  }
+
 }