diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-11-25 07:56:51 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-11-25 07:56:51 +0400 |
commit | 2a4d3e941320c489d7359cde725031432ea96765 (patch) | |
tree | 5952cfb979110447d339cfbafccc29bdf9a03881 /tests/Data/Torrent/MetainfoSpec.hs | |
parent | 087e3435877445c5776e035ec08a26edefb3f7a1 (diff) |
Fix test
Diffstat (limited to 'tests/Data/Torrent/MetainfoSpec.hs')
-rw-r--r-- | tests/Data/Torrent/MetainfoSpec.hs | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/tests/Data/Torrent/MetainfoSpec.hs b/tests/Data/Torrent/MetainfoSpec.hs index 297b28f1..636bb6b1 100644 --- a/tests/Data/Torrent/MetainfoSpec.hs +++ b/tests/Data/Torrent/MetainfoSpec.hs | |||
@@ -7,11 +7,13 @@ import Data.ByteString as BS | |||
7 | import Data.ByteString.Lazy as BL | 7 | import Data.ByteString.Lazy as BL |
8 | import Data.BEncode | 8 | import Data.BEncode |
9 | import Data.Maybe | 9 | import Data.Maybe |
10 | import Data.Time | ||
10 | import Network.URI | 11 | import Network.URI |
11 | import Test.Hspec | 12 | import Test.Hspec |
12 | import Test.QuickCheck | 13 | import Test.QuickCheck |
13 | import Test.QuickCheck.Instances () | 14 | import Test.QuickCheck.Instances () |
14 | 15 | ||
16 | import Data.Torrent.Piece | ||
15 | import Data.Torrent.Layout | 17 | import Data.Torrent.Layout |
16 | import Data.Torrent | 18 | import Data.Torrent |
17 | 19 | ||
@@ -23,8 +25,8 @@ import Data.Torrent | |||
23 | data T a = T | 25 | data T a = T |
24 | 26 | ||
25 | prop_properBEncode :: Show a => BEncode a => Eq a | 27 | prop_properBEncode :: Show a => BEncode a => Eq a |
26 | => T a -> a -> Bool | 28 | => T a -> a -> IO () |
27 | prop_properBEncode _ expected = actual == Right expected | 29 | prop_properBEncode _ expected = actual `shouldBe` Right expected |
28 | where | 30 | where |
29 | actual = decode $ BL.toStrict $ encode expected | 31 | actual = decode $ BL.toStrict $ encode expected |
30 | 32 | ||
@@ -48,13 +50,25 @@ instance Arbitrary LayoutInfo where | |||
48 | , MultiFile <$> arbitrary <*> arbitrary | 50 | , MultiFile <$> arbitrary <*> arbitrary |
49 | ] | 51 | ] |
50 | 52 | ||
53 | instance Arbitrary HashArray where | ||
54 | arbitrary = HashArray <$> arbitrary | ||
55 | |||
56 | instance Arbitrary PieceInfo where | ||
57 | arbitrary = PieceInfo <$> arbitrary <*> arbitrary | ||
58 | |||
51 | instance Arbitrary InfoDict where | 59 | instance Arbitrary InfoDict where |
52 | arbitrary = undefined | 60 | arbitrary = infoDictionary <$> arbitrary <*> arbitrary <*> arbitrary |
61 | |||
62 | pico :: Gen (Maybe NominalDiffTime) | ||
63 | pico = oneof | ||
64 | [ pure Nothing | ||
65 | , (Just . fromIntegral) <$> (arbitrary :: Gen Int) | ||
66 | ] | ||
53 | 67 | ||
54 | instance Arbitrary Torrent where | 68 | instance Arbitrary Torrent where |
55 | arbitrary = Torrent <$> arbitrary | 69 | arbitrary = Torrent <$> arbitrary |
56 | <*> arbitrary <*> arbitrary <*> arbitrary | 70 | <*> arbitrary <*> arbitrary <*> arbitrary |
57 | <*> arbitrary <*> arbitrary <*> arbitrary | 71 | <*> pico <*> arbitrary <*> arbitrary |
58 | <*> arbitrary <*> pure Nothing <*> arbitrary | 72 | <*> arbitrary <*> pure Nothing <*> arbitrary |
59 | 73 | ||
60 | {----------------------------------------------------------------------- | 74 | {----------------------------------------------------------------------- |