Skip to content
Snippets Groups Projects
Commit 4ac6cc5b authored by Hans-Peter Deifel's avatar Hans-Peter Deifel
Browse files

tests: Ensure queue size is always positive

Queue.empty was being called with negative sizes
parent 182e88da
No related branches found
No related tags found
No related merge requests found
......@@ -10,9 +10,6 @@ import Test.QuickCheck
import Control.Monad.ST
import qualified Data.List as List (delete)
import Data.Vector (Vector)
import qualified Data.Vector as V
import Data.BlockQueue
import Data.RefinablePartition (Block(..))
......@@ -24,10 +21,10 @@ spec = do
emptySpec :: Spec
emptySpec = describe "empty" $ do
it "creates an empty queue" $
property $ \sizes -> runST $ empty sizes >>= null
property $ \size -> size >= 0 ==> runST $ empty size >>= null
it "creates a queue where no block is present" $
property $ \size -> runST $ do
property $ \size -> size >= 0 ==> runST $ do
q <- empty size
all not <$> mapM (\b -> Block b `elem` q) [0..size-1]
......@@ -55,7 +52,3 @@ enqueueSpec = describe "enqueue" $ do
Just 0 <- dequeue q
null q
in runST enqtwice `shouldBe` True
instance Arbitrary a => Arbitrary (Vector a) where
arbitrary = V.fromList <$> arbitrary
shrink = fmap V.fromList . shrink . V.toList
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment