Charlotte 🦝 Delenk
f5fda366a1
Some checks failed
Hydra checks.aarch64-darwin.treefmt Hydra build #48478 of flakes:matrix-media-expanded:checks.aarch64-darwin.treefmt
Hydra checks.aarch64-linux.default-hls Hydra build #48479 of flakes:matrix-media-expanded:checks.aarch64-linux.default-hls
Hydra packages.aarch64-linux.default Hydra build #48483 of flakes:matrix-media-expanded:packages.aarch64-linux.default
Hydra packages.x86_64-linux.default Hydra build #48484 of flakes:matrix-media-expanded:packages.x86_64-linux.default
Hydra checks.x86_64-linux.treefmt Hydra build #48482 of flakes:matrix-media-expanded:checks.x86_64-linux.treefmt
Hydra devShells.x86_64-linux.default Hydra build #48480 of flakes:matrix-media-expanded:devShells.x86_64-linux.default
Hydra checks.x86_64-linux.default-hls Hydra build #48481 of flakes:matrix-media-expanded:checks.x86_64-linux.default-hls
Hydra checks.x86_64-darwin.treefmt Hydra build #48485 of flakes:matrix-media-expanded:checks.x86_64-darwin.treefmt
Hydra devShells.aarch64-linux.default Hydra build #48486 of flakes:matrix-media-expanded:devShells.aarch64-linux.default
Hydra checks.aarch64-linux.treefmt Hydra build #48476 of flakes:matrix-media-expanded:checks.aarch64-linux.treefmt
Hydra packages.x86_64-linux.matrix-media-expanded Hydra build #48475 of flakes:matrix-media-expanded:packages.x86_64-linux.matrix-media-expanded
Hydra packages.aarch64-linux.matrix-media-expanded Hydra build #48477 of flakes:matrix-media-expanded:packages.aarch64-linux.matrix-media-expanded
38 lines
1.4 KiB
Haskell
38 lines
1.4 KiB
Haskell
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
|
|
|
|
{-# HLINT ignore "Use alternative" #-}
|
|
module Test.Codec.Multibase.Identity where
|
|
|
|
import Codec.Multibase.Identity
|
|
import Data.ByteString.Builder (toLazyByteString)
|
|
import Data.ByteString.Lazy qualified as B
|
|
import Test.Tasty
|
|
import Test.Tasty.HUnit
|
|
import Test.Tasty.SmallCheck as SC
|
|
|
|
tests :: TestTree
|
|
tests = testGroup "Identity" [scProps, unitTests]
|
|
|
|
encode' :: B.ByteString -> B.ByteString
|
|
encode' = toLazyByteString . encode
|
|
|
|
scProps :: TestTree
|
|
scProps =
|
|
testGroup
|
|
"SmallCheck"
|
|
[ SC.testProperty "decode . encode == id" $ \list ->
|
|
let lazyList = B.pack list
|
|
in decode (encode' lazyList) == Right lazyList
|
|
]
|
|
|
|
unitTests :: TestTree
|
|
unitTests =
|
|
testGroup
|
|
"Unit Tests"
|
|
[ testCase "Encoding the string 'yes mani !'" $ encode' "yes mani !" @?= "\0yes mani !"
|
|
, testCase "Decoding the Multibase '\\0yes mani !'" $ decode "\0yes mani !" @?= Right "yes mani !"
|
|
, testCase "Encoding the string '\\0yes mani !'" $ encode' "\0yes mani !" @?= "\0\0yes mani !"
|
|
, testCase "Decoding the Multibase '\\0\\0yes mani !'" $ decode "\0\0yes mani !" @?= Right "\0yes mani !"
|
|
, testCase "Encoding the string '\\0\\0yes mani !'" $ encode' "\0\0yes mani !" @?= "\0\0\0yes mani !"
|
|
, testCase "Decoding the Multibase '\\0\\0\\0yes mani !'" $ decode "\0\0\0yes mani !" @?= Right "\0\0yes mani !"
|
|
]
|