From d6a0442a56d7b977d5f1d1d162517c9086c413eb Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Tue, 3 Dec 2013 16:15:32 +0400 Subject: New storage --- tests/Data/Torrent/LayoutSpec.hs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/Data/Torrent/LayoutSpec.hs (limited to 'tests/Data/Torrent/LayoutSpec.hs') diff --git a/tests/Data/Torrent/LayoutSpec.hs b/tests/Data/Torrent/LayoutSpec.hs new file mode 100644 index 00000000..d3966b3f --- /dev/null +++ b/tests/Data/Torrent/LayoutSpec.hs @@ -0,0 +1,30 @@ +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE StandaloneDeriving #-} +module Data.Torrent.LayoutSpec (spec) where + +import Control.Applicative +import Test.Hspec +import Test.QuickCheck +import System.Posix.Types + +import Data.Torrent.Layout + + +instance Arbitrary COff where + arbitrary = fromIntegral <$> (arbitrary :: Gen Int) + +instance Arbitrary a => Arbitrary (FileInfo a) where + arbitrary = FileInfo <$> arbitrary <*> arbitrary <*> arbitrary + +instance Arbitrary LayoutInfo where + arbitrary = oneof + [ SingleFile <$> arbitrary + , MultiFile <$> arbitrary <*> arbitrary + ] + +spec :: Spec +spec = do + describe "accumPosition" $ do + it "" $ property $ \ p1 p2 p3 s1 s2 s3 -> + accumPositions [(p1, s1), (p2, s2), (p3, s3)] + `shouldBe` [(p1, (0, s1)), (p2, (s1, s2)), (p3, (s1 + s2, s3))] \ No newline at end of file -- cgit v1.2.3