summaryrefslogtreecommitdiff
path: root/tests/Network/BitTorrent/Exchange/BlockSpec.hs
blob: 158a30b4d86f0a0a07d6de9e2a852d052d91a4c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Network.BitTorrent.Exchange.BlockSpec (spec) where
import Control.Applicative
import Test.Hspec
import Test.QuickCheck

import Network.BitTorrent.Exchange.Block


instance Arbitrary a => Arbitrary (Block a) where
  arbitrary = Block <$> arbitrary <*> arbitrary <*> arbitrary

instance Arbitrary BlockIx where
  arbitrary = BlockIx <$> arbitrary <*> arbitrary <*> arbitrary

spec :: Spec
spec = do
  describe "bucket" $ do
    it "render to piece when it is full" $ property $ \ bkt ->
      if full bkt then isJust (toPiece bkt)