File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -124,16 +124,19 @@ createFile hfs p = withFile hfs p (WriteMode MustBeNew) $ \_ -> pure ()
124124data WithBitOffset a = WithBitOffset Int a
125125 deriving stock Show
126126
127+ bitLength :: BS. ByteString -> Int
128+ bitLength bs = BS. length bs * 8
129+
127130instance Arbitrary (WithBitOffset ByteString ) where
128131 arbitrary = do
129132 bs <- arbitrary `suchThat` (\ bs -> BS. length bs > 0 )
130- bitOffset <- chooseInt (0 , BS. length bs - 1 )
133+ bitOffset <- chooseInt (0 , bitLength bs - 1 )
131134 pure $ WithBitOffset bitOffset bs
132135 shrink (WithBitOffset bitOffset bs) =
133136 [ WithBitOffset bitOffset' bs'
134137 | bs' <- shrink bs
135138 , BS. length bs' > 0
136- , let bitOffset' = max 0 $ min (BS. length bs' - 1 ) bitOffset
139+ , let bitOffset' = max 0 $ min (bitLength bs' - 1 ) bitOffset
137140 ] ++ [
138141 WithBitOffset bitOffset' bs
139142 | bitOffset' <- max 0 <$> shrink bitOffset
You can’t perform that action at this time.
0 commit comments