summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Data/Torrent/ProgressSpec.hs13
-rw-r--r--tests/Network/BitTorrent/Core/PeerIdSpec.hs15
-rw-r--r--tests/Network/BitTorrent/Tracker/MessageSpec.hs47
3 files changed, 75 insertions, 0 deletions
diff --git a/tests/Data/Torrent/ProgressSpec.hs b/tests/Data/Torrent/ProgressSpec.hs
new file mode 100644
index 00000000..32efbd7a
--- /dev/null
+++ b/tests/Data/Torrent/ProgressSpec.hs
@@ -0,0 +1,13 @@
1{-# OPTIONS -fno-warn-orphans #-}
2module Data.Torrent.ProgressSpec (spec) where
3import Control.Applicative
4import Test.Hspec
5import Test.QuickCheck
6import Data.Torrent.Progress
7
8
9instance Arbitrary Progress where
10 arbitrary = Progress <$> arbitrary <*> arbitrary <*> arbitrary
11
12spec :: Spec
13spec = return ()
diff --git a/tests/Network/BitTorrent/Core/PeerIdSpec.hs b/tests/Network/BitTorrent/Core/PeerIdSpec.hs
new file mode 100644
index 00000000..7ed8a976
--- /dev/null
+++ b/tests/Network/BitTorrent/Core/PeerIdSpec.hs
@@ -0,0 +1,15 @@
1module Network.BitTorrent.Core.PeerIdSpec (spec) where
2import Control.Applicative
3import Test.Hspec
4import Test.QuickCheck
5import Network.BitTorrent.Core.PeerId
6
7
8instance Arbitrary PeerId where
9 arbitrary = oneof
10 [ azureusStyle defaultClientId defaultVersionNumber <$> arbitrary
11 , shadowStyle 'X' defaultVersionNumber <$> arbitrary
12 ]
13
14spec :: Spec
15spec = return () \ No newline at end of file
diff --git a/tests/Network/BitTorrent/Tracker/MessageSpec.hs b/tests/Network/BitTorrent/Tracker/MessageSpec.hs
new file mode 100644
index 00000000..62b4ab04
--- /dev/null
+++ b/tests/Network/BitTorrent/Tracker/MessageSpec.hs
@@ -0,0 +1,47 @@
1{-# OPTIONS -fno-warn-orphans #-}
2module Network.BitTorrent.Tracker.MessageSpec (spec) where
3
4import Control.Applicative
5import Data.BEncode as BE
6import Data.ByteString.Lazy as BL
7import Data.Maybe
8import Data.Word
9import Network
10import Network.URI
11import Test.Hspec
12import Test.QuickCheck
13import Network.HTTP.Types.URI
14
15import Data.Torrent.InfoHashSpec hiding (spec)
16import Data.Torrent.ProgressSpec hiding (spec)
17import Network.BitTorrent.Core.PeerIdSpec hiding (spec)
18
19import Network.BitTorrent.Tracker.Message
20
21
22prop_bencode :: Eq a => BEncode a => a -> Bool
23prop_bencode a = BE.decode (BL.toStrict (BE.encode a)) == return a
24
25--prop_urlencode :: Eq a => URLDecoded a => URLEncoded a => a -> Bool
26--prop_urlencode a = urlDecode (T.pack (urlEncode a)) == a
27
28instance Arbitrary Event where
29 arbitrary = elements [minBound..maxBound]
30
31instance Arbitrary PortNumber where
32 arbitrary = fromIntegral <$> (arbitrary :: Gen Word16)
33
34instance Arbitrary AnnounceQuery where
35 arbitrary = AnnounceQuery
36 <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
37 <*> arbitrary <*> arbitrary <*> arbitrary
38
39baseURI :: URI
40baseURI = fromJust $ parseURI "http://a"
41
42spec :: Spec
43spec = do
44 describe "Announce" $ do
45 return ()
46 describe "Scrape" $ do
47 return ()