lz4-hs-0.1.1.0: test/Spec.hs
module Main (main) where
import Codec.Lz4
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as BSL
import Test.Tasty
import Test.Tasty.HUnit
testRoundtripBlocks :: FilePath -> TestTree
testRoundtripBlocks fp = testCase ("Roundtrip " ++ fp) $ do
contents <- BS.readFile fp
let sz = BS.length contents
actual = decompressBlockSz (compressBlock contents) sz
actual @?= contents
testRoundtripFrames :: FilePath -> TestTree
testRoundtripFrames fp = testCase ("Roundtrip " ++ fp) $ do
contents <- BSL.readFile fp
let actual = decompress (compress contents)
actual @?= contents
main :: IO ()
main =
defaultMain $
testGroup "lz4" [testBlocks, testFrames]
where
testBlocks = testGroup "Block compression"
[ testRoundtripBlocks "lz4-hs.cabal"
, testRoundtripBlocks "LICENSE"
]
testFrames = testGroup "Frame compression"
[ testRoundtripFrames "cbits/lz4.c"
]