From 6aca0216aab2fc5c70593ca3b0cb260364728418 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 14 Sep 2023 11:22:52 -0400 Subject: [PATCH] Added more unit tests for ImapEncodings --- UnitTests/Net/Imap/ImapEncodingTests.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/UnitTests/Net/Imap/ImapEncodingTests.cs b/UnitTests/Net/Imap/ImapEncodingTests.cs index 22f72941a9..68d1e91ef1 100644 --- a/UnitTests/Net/Imap/ImapEncodingTests.cs +++ b/UnitTests/Net/Imap/ImapEncodingTests.cs @@ -34,6 +34,18 @@ namespace UnitTests.Net.Imap { [TestFixture] public class ImapEncodingTests { + [Test] + public void TestAmpersand () + { + const string text = "Jack & Jill"; + + var encoded = ImapEncoding.Encode (text); + Assert.AreEqual ("Jack &- Jill", encoded, "UTF-7 encoded text does not match the expected value: {0}", encoded); + + var decoded = ImapEncoding.Decode (encoded); + Assert.AreEqual (text, decoded, "UTF-7 decoded text does not match the original text: {0}", decoded); + } + [Test] public void TestArabicExample () { @@ -105,6 +117,15 @@ public void TestDecodeBadRfc3501Example () Assert.AreEqual (encoded, decoded, "UTF-7 decoded text does not match the original text: {0}", decoded); } + [Test] + public void TestDecodeInvalidUtf7 () + { + const string encoded = "&台北日本語"; + + var decoded = ImapEncoding.Decode (encoded); + Assert.AreEqual (encoded, decoded, "UTF-7 decoded text does not match the original text: {0}", decoded); + } + [Test] public void TestRfc3501SuperfluousShiftExample () {