[geary/mjog/message-id-db] Geary.RFC822.MessageIDList: Add unit tests for parsing RFC822 id lists
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/message-id-db] Geary.RFC822.MessageIDList: Add unit tests for parsing RFC822 id lists
- Date: Thu, 13 Aug 2020 07:55:59 +0000 (UTC)
commit 175c7dc7f2e0cca33af1caaa1e57188fe84e5bfd
Author: Michael Gratton <mike vee net>
Date: Thu Aug 13 17:55:07 2020 +1000
Geary.RFC822.MessageIDList: Add unit tests for parsing RFC822 id lists
test/engine/rfc822/rfc822-message-data-test.vala | 105 +++++++++++++++++++++++
1 file changed, 105 insertions(+)
---
diff --git a/test/engine/rfc822/rfc822-message-data-test.vala
b/test/engine/rfc822/rfc822-message-data-test.vala
index acc08cb1b..8c1eb157a 100644
--- a/test/engine/rfc822/rfc822-message-data-test.vala
+++ b/test/engine/rfc822/rfc822-message-data-test.vala
@@ -15,6 +15,7 @@ class Geary.RFC822.MessageDataTest : TestCase {
add_test("header_from_rfc822", header_from_rfc822);
add_test("header_names_from_rfc822", header_names_from_rfc822);
add_test("PreviewText.with_header", preview_text_with_header);
+ add_test("MessageIDList.from_rfc822_string", message_id_list_from_rfc822_string);
}
public void preview_text_with_header() throws GLib.Error {
@@ -108,6 +109,110 @@ class Geary.RFC822.MessageDataTest : TestCase {
assert_equal(neg_half_hour_tz.to_rfc822_string(), NEG_HALF_HOUR_TZ);
}
+ public void message_id_list_from_rfc822_string() throws GLib.Error {
+
+ // Standard variants
+
+ assert_collection(
+ new MessageIDList.from_rfc822_string("<id example com>").get_all(),
+ "<id example com>"
+ )
+ .size(1)
+ .contains(new MessageID("id example com"));
+
+ assert_collection(
+ new MessageIDList.from_rfc822_string("<id1 example com><id2 example com>").get_all(),
+ "<id1 example com><id2 example com>"
+ )
+ .size(2)
+ .contains(new MessageID("id1 example com"))
+ .contains(new MessageID("id2 example com"));
+
+ assert_collection(
+ new MessageIDList.from_rfc822_string("<id1 example com> <id2 example com>").get_all(),
+ "<id1 example com> <id2 example com>"
+ )
+ .size(2)
+ .contains(new MessageID("id1 example com"))
+ .contains(new MessageID("id2 example com"));
+
+ // Parens as delim are invalid but seen in the wild
+
+ assert_collection(
+ new MessageIDList.from_rfc822_string("(id example com)").get_all(),
+ "(id example com)"
+ )
+ .size(1)
+ .contains(new MessageID("id example com"));
+
+ assert_collection(
+ new MessageIDList.from_rfc822_string("(id1 example com)(id2 example com>").get_all(),
+ "(id1 example com)(id2 example com>"
+ )
+ .size(2)
+ .contains(new MessageID("id1 example com"))
+ .contains(new MessageID("id2 example com"));
+
+ assert_collection(
+ new MessageIDList.from_rfc822_string("(id1 example com) (id2 example com)").get_all(),
+ "(id1 example com) (id2 example com)"
+ )
+ .size(2)
+ .contains(new MessageID("id1 example com"))
+ .contains(new MessageID("id2 example com"));
+
+ // No delimiters
+
+ assert_collection(
+ new MessageIDList.from_rfc822_string("id example com").get_all(),
+ "id example com"
+ )
+ .size(1)
+ .contains(new MessageID("id example com"));
+
+ assert_collection(
+ new MessageIDList.from_rfc822_string("id1 example com id2 example com").get_all(),
+ "id1 example com id2 example com"
+ )
+ .size(2)
+ .contains(new MessageID("id1 example com"))
+ .contains(new MessageID("id2 example com"));
+
+ // Comma-separated is invalid but seen in the wild
+
+ assert_collection(
+ new MessageIDList.from_rfc822_string("<id1 example com>,<id2 example com>").get_all(),
+ "<id1 example com>,<id2 example com>"
+ )
+ .size(2)
+ .contains(new MessageID("id1 example com"))
+ .contains(new MessageID("id2 example com"));
+
+ assert_collection(
+ new MessageIDList.from_rfc822_string("<id1 example com>, <id2 example com>").get_all(),
+ "<id1 example com>, <id2 example com>"
+ )
+ .size(2)
+ .contains(new MessageID("id1 example com"))
+ .contains(new MessageID("id2 example com"));
+
+ assert_collection(
+ new MessageIDList.from_rfc822_string("(id1 example com),(id2 example com)").get_all(),
+ "(id1 example com),(id2 example com)"
+ )
+ .size(2)
+ .contains(new MessageID("id1 example com"))
+ .contains(new MessageID("id2 example com"));
+
+ assert_collection(
+ new MessageIDList.from_rfc822_string("(id1 example com), (id2 example com)").get_all(),
+ "(id1 example com), (id2 example com)"
+ )
+ .size(2)
+ .contains(new MessageID("id1 example com"))
+ .contains(new MessageID("id2 example com"));
+ }
+
private const string HEADER_FIXTURE = """From: Test <test example com>
Subject: test
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]