summaryrefslogtreecommitdiff
path: root/tests/Data/Torrent
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-11-25 07:56:51 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-11-25 07:56:51 +0400
commit2a4d3e941320c489d7359cde725031432ea96765 (patch)
tree5952cfb979110447d339cfbafccc29bdf9a03881 /tests/Data/Torrent
parent087e3435877445c5776e035ec08a26edefb3f7a1 (diff)
Fix test
Diffstat (limited to 'tests/Data/Torrent')
-rw-r--r--tests/Data/Torrent/ClientSpec.hs5
-rw-r--r--tests/Data/Torrent/MagnetSpec.hs3
-rw-r--r--tests/Data/Torrent/MetainfoSpec.hs24
3 files changed, 25 insertions, 7 deletions
diff --git a/tests/Data/Torrent/ClientSpec.hs b/tests/Data/Torrent/ClientSpec.hs
index 0ff74f6f..4bc881c3 100644
--- a/tests/Data/Torrent/ClientSpec.hs
+++ b/tests/Data/Torrent/ClientSpec.hs
@@ -27,4 +27,7 @@ spec = do
27 clientInfo "OP0123xxxxxxxxxxxxxx" `shouldBe` "Opera-123" 27 clientInfo "OP0123xxxxxxxxxxxxxx" `shouldBe` "Opera-123"
28 28
29 it "decode ML donkey style peer id" $ do 29 it "decode ML donkey style peer id" $ do
30 clientInfo "-ML2.7.2-xxxxxxxxxxx" `shouldBe` "MLdonkey-0" \ No newline at end of file 30 clientInfo "-ML2.7.2-xxxxxxxxxxx" `shouldBe` "MLdonkey-0"
31
32-- TODO XBT, Bits on Wheels, Queen Bee, BitTyrant, TorrenTopia,
33-- BitSpirit, Rufus, G3 Torrent, FlashGet \ No newline at end of file
diff --git a/tests/Data/Torrent/MagnetSpec.hs b/tests/Data/Torrent/MagnetSpec.hs
index 5adc6df7..3ecf8705 100644
--- a/tests/Data/Torrent/MagnetSpec.hs
+++ b/tests/Data/Torrent/MagnetSpec.hs
@@ -3,6 +3,7 @@ module Data.Torrent.MagnetSpec (spec) where
3 3
4import Control.Applicative 4import Control.Applicative
5import Data.Maybe 5import Data.Maybe
6import Data.Monoid
6import Test.Hspec 7import Test.Hspec
7import Test.QuickCheck 8import Test.QuickCheck
8import Test.QuickCheck.Instances () 9import Test.QuickCheck.Instances ()
@@ -23,7 +24,7 @@ instance Arbitrary URI where
23instance Arbitrary Magnet where 24instance Arbitrary Magnet where
24 arbitrary = Magnet <$> arbitrary <*> arbitrary 25 arbitrary = Magnet <$> arbitrary <*> arbitrary
25 <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary 26 <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
26 <*> arbitrary <*> arbitrary <*> pure (error "arbitrary magnet") 27 <*> arbitrary <*> arbitrary <*> pure mempty
27 28
28magnetEncoding :: Magnet -> Bool 29magnetEncoding :: Magnet -> Bool
29magnetEncoding m = parseMagnet (renderMagnet m) == Just m 30magnetEncoding m = parseMagnet (renderMagnet m) == Just m
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
7import Data.ByteString.Lazy as BL 7import Data.ByteString.Lazy as BL
8import Data.BEncode 8import Data.BEncode
9import Data.Maybe 9import Data.Maybe
10import Data.Time
10import Network.URI 11import Network.URI
11import Test.Hspec 12import Test.Hspec
12import Test.QuickCheck 13import Test.QuickCheck
13import Test.QuickCheck.Instances () 14import Test.QuickCheck.Instances ()
14 15
16import Data.Torrent.Piece
15import Data.Torrent.Layout 17import Data.Torrent.Layout
16import Data.Torrent 18import Data.Torrent
17 19
@@ -23,8 +25,8 @@ import Data.Torrent
23data T a = T 25data T a = T
24 26
25prop_properBEncode :: Show a => BEncode a => Eq a 27prop_properBEncode :: Show a => BEncode a => Eq a
26 => T a -> a -> Bool 28 => T a -> a -> IO ()
27prop_properBEncode _ expected = actual == Right expected 29prop_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
53instance Arbitrary HashArray where
54 arbitrary = HashArray <$> arbitrary
55
56instance Arbitrary PieceInfo where
57 arbitrary = PieceInfo <$> arbitrary <*> arbitrary
58
51instance Arbitrary InfoDict where 59instance Arbitrary InfoDict where
52 arbitrary = undefined 60 arbitrary = infoDictionary <$> arbitrary <*> arbitrary <*> arbitrary
61
62pico :: Gen (Maybe NominalDiffTime)
63pico = oneof
64 [ pure Nothing
65 , (Just . fromIntegral) <$> (arbitrary :: Gen Int)
66 ]
53 67
54instance Arbitrary Torrent where 68instance 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{-----------------------------------------------------------------------