diff options
Diffstat (limited to 'tests/Data/Torrent/MagnetSpec.hs')
-rw-r--r-- | tests/Data/Torrent/MagnetSpec.hs | 44 |
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 #-} | ||
2 | module Data.Torrent.MagnetSpec (spec) where | ||
3 | |||
4 | import Control.Applicative | ||
5 | import Data.Maybe | ||
6 | import Data.Monoid | ||
7 | import Test.Hspec | ||
8 | import Test.QuickCheck | ||
9 | import Test.QuickCheck.Instances () | ||
10 | import Network.URI | ||
11 | |||
12 | import Data.Torrent | ||
13 | import Data.Torrent.InfoHashSpec () | ||
14 | |||
15 | |||
16 | instance Arbitrary URIAuth where | ||
17 | arbitrary = URIAuth <$> arbitrary <*> arbitrary <*> arbitrary | ||
18 | |||
19 | instance Arbitrary URI where | ||
20 | arbitrary | ||
21 | = pure $ fromJust $ parseURI "http://ietf.org/1737.txt?a=1&b=h#123" | ||
22 | |||
23 | instance Arbitrary Magnet where | ||
24 | arbitrary = Magnet <$> arbitrary <*> arbitrary | ||
25 | <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary | ||
26 | <*> arbitrary <*> arbitrary <*> pure mempty | ||
27 | |||
28 | magnetEncoding :: Magnet -> IO () | ||
29 | magnetEncoding m = parseMagnet (renderMagnet m) `shouldBe` Just m | ||
30 | |||
31 | spec :: Spec | ||
32 | spec = 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) | ||