added tests for base91 and base85

This commit is contained in:
Stefan Friese 2024-06-04 21:59:23 +02:00
parent 580792ddf6
commit 15abc2c95b
1 changed files with 33 additions and 5 deletions

View File

@ -1,6 +1,8 @@
module Main where
import Test.HUnit
import Encoding.Base91 (enc91, dec91)
import Encoding.Base85 (enc85, dec85)
import Encoding.Base64 (enc64, dec64)
import Encoding.Base45 (enc45, dec45)
import Encoding.Base32 (enc32, dec32)
@ -9,7 +11,30 @@ import Encoding.Base8 (enc8, dec8)
import Encoding.Base2 (enc2, dec2)
import System.Exit (exitFailure, exitSuccess)
-- Test cases for enc64 function
testEnc91 :: Test
testEnc91 = TestCase $ do
assertEqual "for (enc91 \"Hello, World!\")," ">OwJh>}AQ;r@@Y?F" (enc91 "Hello, World!")
assertEqual "for (enc91 \"Haskell\")," "3D8=d,[*G" (enc91 "Haskell")
assertEqual "for (enc91 \"😂\")," "=~m6g" (enc91 "😂")
testDec91 :: Test
testDec91 = TestCase $ do
assertEqual "for (dec91 \">OwJh>}AQ;r@@Y?F\")," "Hello, World!" (dec91 ">OwJh>}AQ;r@@Y?F")
assertEqual "for (dec91 \"3D8=d,[*G\")," "Haskell" (dec91 "3D8=d,[*G")
assertEqual "for (dec91 \"=~m6g\")," "😂" (dec91 "=~m6g")
testEnc85 :: Test
testEnc85 = TestCase $ do
assertEqual "for (enc85 \"Hello, World!\")," "87cURD_*#4DfTZ)+T" (enc85 "Hello, World!")
assertEqual "for (enc85 \"Haskell\")," "87?RTASc/" (enc85 "Haskell")
assertEqual "for (enc85 \"😂\")," "n=Q)\"" (enc85 "😂")
testDec85 :: Test
testDec85 = TestCase $ do
assertEqual "for (dec85 \"87cURD_*#4DfTZ)+T\")," "Hello, World!" (dec85 "87cURD_*#4DfTZ)+T")
assertEqual "for (dec85 \"87?RTASc/\")," "Haskell" (dec85 "87?RTASc/")
assertEqual "for (dec85 \"n=Q)\"\")," "😂" (dec85 "n=Q)\"")
testEnc64 :: Test
testEnc64 = TestCase $ do
assertEqual "for (enc64 \"hello\")," "aGVsbG8=" (enc64 "hello")
@ -17,7 +42,6 @@ testEnc64 = TestCase $ do
assertEqual "for (enc64 \"\x00\x01\x02\")," "AAEC" (enc64 "\x00\x01\x02")
assertEqual "for (enc64 \"😂\")," "8J+Ygg==" (enc64 "😂")
-- Test cases for dec64 function
testDec64 :: Test
testDec64 = TestCase $ do
assertEqual "for (dec64 \"aGVsbG8=\")," "hello" (dec64 "aGVsbG8=")
@ -87,10 +111,14 @@ testDec2 = TestCase $ do
assertEqual "for (dec2 \"11110000 10011111 10011000 10000010\")," "😂" (dec2 "11110000 10011111 10011000 10000010")
tests :: Test
tests = TestList [TestLabel "Test enc64" testEnc64,
tests = TestList [TestLabel "Test enc91" testEnc91,
TestLabel "Test dec91" testDec91,
TestLabel "Test enc85" testEnc85,
TestLabel "Test dec85" testDec85,
TestLabel "Test enc64" testEnc64,
TestLabel "Test dec64" testDec64,
TestLabel "Test enc32" testEnc45,
TestLabel "Test dec32" testDec45,
TestLabel "Test enc45" testEnc45,
TestLabel "Test dec45" testDec45,
TestLabel "Test enc32" testEnc32,
TestLabel "Test dec32" testDec32,
TestLabel "Test enc16" testEnc16,