[geary/wip/282-composer-quoted-email: 1/3] Add some tests for decoding/encoding quoted names in RFC822 mailboxes
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/282-composer-quoted-email: 1/3] Add some tests for decoding/encoding quoted names in RFC822 mailboxes
- Date: Sat, 2 Mar 2019 04:06:57 +0000 (UTC)
commit 9ba7c75cd4160129e00251dd7401d32789916890
Author: Michael Gratton <mike vee net>
Date: Sat Mar 2 14:25:21 2019 +1100
Add some tests for decoding/encoding quoted names in RFC822 mailboxes
test/engine/rfc822-mailbox-address-test.vala | 15 ++++++++++++++-
test/engine/rfc822-mailbox-addresses-test.vala | 14 +++++++++++++-
2 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/test/engine/rfc822-mailbox-address-test.vala b/test/engine/rfc822-mailbox-address-test.vala
index 501706ad..1381d366 100644
--- a/test/engine/rfc822-mailbox-address-test.vala
+++ b/test/engine/rfc822-mailbox-address-test.vala
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2018 Michael Gratton <mike vee net>
+ * Copyright 2016-2019 Michael Gratton <mike vee net>
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
@@ -38,6 +38,8 @@ class Geary.RFC822.MailboxAddressTest : TestCase {
assert(Geary.RFC822.MailboxAddress.is_valid_address("test@") == false);
assert(Geary.RFC822.MailboxAddress.is_valid_address("@") == false);
assert(Geary.RFC822.MailboxAddress.is_valid_address("") == false);
+
+ assert(Geary.RFC822.MailboxAddress.is_valid_address("\"Surname, Name\" <mail example com>") == true);
}
public void unescaped_constructor() throws Error {
@@ -260,6 +262,17 @@ class Geary.RFC822.MailboxAddressTest : TestCase {
"=?iso-8859-1?b?qQ==?= <example example com>");
assert(new MailboxAddress("😸", "example example com").to_rfc822_string() ==
"=?UTF-8?b?8J+YuA==?= <example example com>");
+
+ assert_string(
+ "\"Surname, Name\" <example example com>",
+ new MailboxAddress("Surname, Name", "example example com").to_rfc822_string()
+ );
+ assert_string(
+ "\"Surname, Name\" <example example com>",
+ new MailboxAddress
+ .from_rfc822_string("\"Surname, Name\" <example example com>")
+ .to_rfc822_string()
+ );
}
public void equal_to() throws GLib.Error {
diff --git a/test/engine/rfc822-mailbox-addresses-test.vala b/test/engine/rfc822-mailbox-addresses-test.vala
index 45853a0a..6c3a59b1 100644
--- a/test/engine/rfc822-mailbox-addresses-test.vala
+++ b/test/engine/rfc822-mailbox-addresses-test.vala
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 Michael Gratton <mike vee net>
+ * Copyright 2018-2019 Michael Gratton <mike vee net>
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
@@ -10,6 +10,7 @@ class Geary.RFC822.MailboxAddressesTest : TestCase {
public MailboxAddressesTest() {
base("Geary.RFC822.MailboxAddressesTest");
add_test("from_rfc822_string_encoded", from_rfc822_string_encoded);
+ add_test("from_rfc822_string_quoted", from_rfc822_string_quoted);
add_test("to_rfc822_string", to_rfc822_string);
}
@@ -29,6 +30,17 @@ class Geary.RFC822.MailboxAddressesTest : TestCase {
assert(addrs.size == 2);
}
+ public void from_rfc822_string_quoted() throws GLib.Error {
+ MailboxAddresses addrs = new MailboxAddresses.from_rfc822_string(
+ "\"Surname, Name\" <mail example com>"
+ ) ;
+ assert_int(1, addrs.size);
+ assert_string("Surname, Name", addrs[0].name);
+ assert_string("mail example com", addrs[0].address);
+
+ assert_string("\"Surname, Name\" <mail example com>", addrs.to_rfc822_string());
+ }
+
public void to_rfc822_string() throws Error {
assert(new MailboxAddresses().to_rfc822_string() == "");
assert(new_addreses({ "test1 example com" })
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]