diff options
author | Justin Bedo <cu@cua0.org> | 2023-08-18 11:31:44 +1000 |
---|---|---|
committer | Justin Bedo <cu@cua0.org> | 2023-08-18 11:34:03 +1000 |
commit | e17f009dc5f1750f47f4ef950b2032b4bd283e67 (patch) | |
tree | 7c553834c65179739defa3230e6f30cc0d5073a5 /test.hs | |
parent | 2765051c4533483d11b2ea3fb4c660e74300ef01 (diff) |
add tests and bugfix for small BGZip files
Diffstat (limited to 'test.hs')
-rw-r--r-- | test.hs | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -0,0 +1,33 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE QuasiQuotes #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module Main where + +import qualified Data.ByteString.Char8 as B +import Data.FastQ +import Data.Function +import qualified Streamly.Data.Fold as F +import qualified Streamly.Data.Stream as S +import qualified Streamly.Data.Unfold as U +import Test.QuickCheck +import Test.QuickCheck.Arbitrary +import Test.QuickCheck.Monadic +import Prelude hiding (Read) + +instance Arbitrary Read where + arbitrary = Read <$> genStr <*> genStr <*> genStr + where + genBS = fmap B.pack . listOf . elements + genStr = genBS $ [' ' .. '*'] ++ [',' .. '?'] ++ ['A' .. '~'] + +main :: IO () +main = quickCheckWith stdArgs {maxSuccess = 10000} $ \rp -> monadicIO $ do + rp' <- run $ do + S.unfold U.fromList rp & unparse "a" "b" + cnt <- B.readFile "a" + B.writeFile "a" $ cnt <> cnt + cnt <- B.readFile "b" + B.writeFile "b" $ cnt <> cnt + parse "a" "b" & S.fold F.toList + assert $ rp <> rp == rp' |