diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-03 16:15:32 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-03 16:15:32 +0400 |
commit | d6a0442a56d7b977d5f1d1d162517c9086c413eb (patch) | |
tree | 83a1de6acdd77c7bc1ae60c7418a6f43927251c6 /tests/Data/Torrent/LayoutSpec.hs | |
parent | 5570963d8b22713d4f6ed9c0e2c7f686d5bc75da (diff) |
New storage
Diffstat (limited to 'tests/Data/Torrent/LayoutSpec.hs')
-rw-r--r-- | tests/Data/Torrent/LayoutSpec.hs | 30 |
1 files changed, 30 insertions, 0 deletions
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 @@ | |||
1 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
2 | {-# LANGUAGE StandaloneDeriving #-} | ||
3 | module Data.Torrent.LayoutSpec (spec) where | ||
4 | |||
5 | import Control.Applicative | ||
6 | import Test.Hspec | ||
7 | import Test.QuickCheck | ||
8 | import System.Posix.Types | ||
9 | |||
10 | import Data.Torrent.Layout | ||
11 | |||
12 | |||
13 | instance Arbitrary COff where | ||
14 | arbitrary = fromIntegral <$> (arbitrary :: Gen Int) | ||
15 | |||
16 | instance Arbitrary a => Arbitrary (FileInfo a) where | ||
17 | arbitrary = FileInfo <$> arbitrary <*> arbitrary <*> arbitrary | ||
18 | |||
19 | instance Arbitrary LayoutInfo where | ||
20 | arbitrary = oneof | ||
21 | [ SingleFile <$> arbitrary | ||
22 | , MultiFile <$> arbitrary <*> arbitrary | ||
23 | ] | ||
24 | |||
25 | spec :: Spec | ||
26 | spec = do | ||
27 | describe "accumPosition" $ do | ||
28 | it "" $ property $ \ p1 p2 p3 s1 s2 s3 -> | ||
29 | accumPositions [(p1, s1), (p2, s2), (p3, s3)] | ||
30 | `shouldBe` [(p1, (0, s1)), (p2, (s1, s2)), (p3, (s1 + s2, s3))] \ No newline at end of file | ||