summaryrefslogtreecommitdiff
path: root/tests/Data/Torrent/MagnetSpec.hs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Data/Torrent/MagnetSpec.hs')
-rw-r--r--tests/Data/Torrent/MagnetSpec.hs44
1 files changed, 0 insertions, 44 deletions
diff --git a/tests/Data/Torrent/MagnetSpec.hs b/tests/Data/Torrent/MagnetSpec.hs
deleted file mode 100644
index 838df570..00000000
--- a/tests/Data/Torrent/MagnetSpec.hs
+++ /dev/null
@@ -1,44 +0,0 @@
1{-# OPTIONS -fno-warn-orphans #-}
2module Data.Torrent.MagnetSpec (spec) where
3
4import Control.Applicative
5import Data.Maybe
6import Data.Monoid
7import Test.Hspec
8import Test.QuickCheck
9import Test.QuickCheck.Instances ()
10import Network.URI
11
12import Data.Torrent
13import Data.Torrent.InfoHashSpec ()
14
15
16instance Arbitrary URIAuth where
17 arbitrary = URIAuth <$> arbitrary <*> arbitrary <*> arbitrary
18
19instance Arbitrary URI where
20 arbitrary
21 = pure $ fromJust $ parseURI "http://ietf.org/1737.txt?a=1&b=h#123"
22
23instance Arbitrary Magnet where
24 arbitrary = Magnet <$> arbitrary <*> arbitrary
25 <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
26 <*> arbitrary <*> arbitrary <*> pure mempty
27
28magnetEncoding :: Magnet -> IO ()
29magnetEncoding m = parseMagnet (renderMagnet m) `shouldBe` Just m
30
31spec :: Spec
32spec = do
33 describe "Magnet" $ do
34 it "properly encoded" $ property $ magnetEncoding
35
36 it "parse base32" $ do
37 let magnet = "magnet:?xt=urn:btih:CT76LXJDDCH5LS2TUHKH6EUJ3NYKX4Y6"
38 let ih = "CT76LXJDDCH5LS2TUHKH6EUJ3NYKX4Y6"
39 parseMagnet magnet `shouldBe` Just (nullMagnet ih)
40
41 it "parse base16" $ do
42 let magnet = "magnet:?xt=urn:btih:0123456789abcdef0123456789abcdef01234567"
43 let ih = "0123456789abcdef0123456789abcdef01234567"
44 parseMagnet magnet `shouldBe` Just (nullMagnet ih)