on 294aa21 help sign in
27 lines 862 B history raw
1module Main (main) where
3import qualified Streamly.Prelude as S
4import Streamly.Internal.Data.Fold
6import Test.Hspec.QuickCheck
7import Test.QuickCheck (Property, forAll, Gen, vectorOf, arbitrary, choose)
8import Test.QuickCheck.Monadic (monadicIO, assert, run)
10import Test.Hspec as H
12maxStreamLen :: Int
13maxStreamLen = 1000
15testRollingHashFirstN :: Property
16testRollingHashFirstN =
17 forAll (choose (0, maxStreamLen)) $ \len ->
18 forAll (choose (0, len)) $ \n ->
19 forAll (vectorOf len (arbitrary :: Gen Int)) $ \vec -> monadicIO $ do
20 a <- run $ S.fold rollingHash $ S.take n $ S.fromList vec
21 b <- run $ S.fold (rollingHashFirstN n) $ S.fromList vec
22 assert $ a == b
24main :: IO ()
25main = hspec $
26 describe "Rolling Hash Folds" $
27 prop "testRollingHashFirstN" testRollingHashFirstN