added test for quoted printable encoding and decoding

This commit is contained in:
Stefan Friese 2024-06-06 13:13:14 +02:00
parent 15abc2c95b
commit 550f40ce4a
1 changed files with 16 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import Encoding.Base32 (enc32, dec32)
import Encoding.Base16 (enc16, dec16)
import Encoding.Base8 (enc8, dec8)
import Encoding.Base2 (enc2, dec2)
import Encoding.QuotedPrintable (encqp, decqp)
import System.Exit (exitFailure, exitSuccess)
testEnc91 :: Test
@ -110,6 +111,18 @@ testDec2 = TestCase $ do
assertEqual "for (dec2 \"01001000 01100001 01110011 01101011 01100101 01101100 01101100\")," "Haskell" (dec2 "01001000 01100001 01110011 01101011 01100101 01101100 01101100")
assertEqual "for (dec2 \"11110000 10011111 10011000 10000010\")," "😂" (dec2 "11110000 10011111 10011000 10000010")
testEncQp :: Test
testEncQp = TestCase $ do
assertEqual "for (encqp \"Hello, World!\")," "Hello,=20World!" (encqp "Hello, World!")
assertEqual "for (encqp \"QP works by using the equals sign = as an escape character. It also limits line length to 76, as some software has limits on line length.\")," "QP=20works=20by=20using=20the=20equals=20sign=20=3D=20as=20an=20escape=20=\r\ncharacter.=20It=20also=20limits=20line=20length=20to=2076,=20as=20some=20=\r\nsoftware=20has=20limits=20on=20line=20length." (encqp "QP works by using the equals sign = as an escape character. It also limits line length to 76, as some software has limits on line length.")
assertEqual "for (encqp \"😂\")," "=F0=9F=98=82" (encqp "😂")
testDecQp :: Test
testDecQp = TestCase $ do
assertEqual "for (decqp \"Hello,=20World!\")," "Hello, World!" (decqp "Hello,=20World!")
assertEqual "for (decqp \"QP=20works=20by=20using=20the=20equals=20sign=20=3D=20as=20an=20escape=20=\r\ncharacter.=20It=20also=20limits=20line=20length=20to=2076,=20as=20some=20=\r\nsoftware=20has=20limits=20on=20line=20length.\")," "QP works by using the equals sign = as an escape character. It also limits line length to 76, as some software has limits on line length." (decqp "QP=20works=20by=20using=20the=20equals=20sign=20=3D=20as=20an=20escape=20=\ncharacter.=20It=20also=20limits=20line=20length=20to=2076,=20as=20some=20=\nsoftware=20has=20limits=20on=20line=20length.")
assertEqual "for (decqp \"=F0=9F=98=82\")," "😂" (decqp "=F0=9F=98=82")
tests :: Test
tests = TestList [TestLabel "Test enc91" testEnc91,
TestLabel "Test dec91" testDec91,
@ -126,7 +139,9 @@ tests = TestList [TestLabel "Test enc91" testEnc91,
TestLabel "Test enc8 " testEnc8 ,
TestLabel "Test dec8 " testDec8 ,
TestLabel "Test dec2 " testDec2 ,
TestLabel "Test enc2 " testEnc2 ]
TestLabel "Test enc2 " testEnc2 ,
TestLabel "Test decqp" testDecQp,
TestLabel "Test encqp" testEncQp]
-- main :: IO Counts