{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} module HaskellWorks.Data.RankSelect.CsPoppy.InternalSpec (spec) where import HaskellWorks.Data.Bits.BitWise import HaskellWorks.Data.RankSelect.CsPoppy.Internal import HaskellWorks.Hspec.Hedgehog import Hedgehog import Prelude hiding (length) import Test.Hspec import qualified Hedgehog.Gen as G import qualified Hedgehog.Range as R {-# ANN module ("HLint: ignore Redundant do" :: String) #-} {-# ANN module ("HLint: ignore Reduce duplication" :: String) #-} spec :: Spec spec = describe "HaskellWorks.Data.RankSelect.CsInterleavedSpec" $ do describe "Interleaved Level 1 & 2" $ do it "have all its fields isolated" $ require $ property $ do vx <- forAll $ G.word64 R.constantBounded va <- forAll $ G.word64 R.constantBounded vb <- forAll $ G.word64 R.constantBounded vc <- forAll $ G.word64 R.constantBounded let actual = putCsiX vx . putCsiA va . putCsiB vb . putCsiC vc $ CsInterleaved 0 getCsiX (putCsiX vx actual) === (vx .&. 0xffffffff) getCsiA (putCsiA va actual) === (va .&. 0x3ff) getCsiB (putCsiB vb actual) === (vb .&. 0x3ff) getCsiC (putCsiC vc actual) === (vc .&. 0x3ff) it "have all its fields isolated" $ require $ property $ do vx <- forAll $ G.word64 R.constantBounded va <- forAll $ G.word64 R.constantBounded vb <- forAll $ G.word64 R.constantBounded vc <- forAll $ G.word64 R.constantBounded getCsiX (putCsiX vx (CsInterleaved 0)) === (vx .&. 0xffffffff) getCsiA (putCsiA va (CsInterleaved 0)) === (va .&. 0x3ff) getCsiB (putCsiB vb (CsInterleaved 0)) === (vb .&. 0x3ff) getCsiC (putCsiC vc (CsInterleaved 0)) === (vc .&. 0x3ff)