X-Git-Url: https://git.rkrishnan.org/?a=blobdiff_plain;f=test%2FMetainfoTests.hs;h=86aa0ff14b5632dece355c52a2f72be23c666a2d;hb=4861358f5573fb9ed27eda0dda72dd2ba1022e84;hp=824bb64ee1d50568e1ba81c84ced0269ab51516d;hpb=1b29012aa1e98cbd35bf5fc2c2d076a38a04da3b;p=functorrent.git diff --git a/test/MetainfoTests.hs b/test/MetainfoTests.hs index 824bb64..86aa0ff 100644 --- a/test/MetainfoTests.hs +++ b/test/MetainfoTests.hs @@ -1,5 +1,24 @@ -- | Tests for Metainfo module +{- + - Copyright (C) 2015-2016 Ramakrishnan Muthukrishnan + - + - This file is part of FuncTorrent. + - + - FuncTorrent is free software; you can redistribute it and/or modify + - it under the terms of the GNU General Public License as published by + - the Free Software Foundation; either version 3 of the License, or + - (at your option) any later version. + - + - FuncTorrent is distributed in the hope that it will be useful, + - but WITHOUT ANY WARRANTY; without even the implied warranty of + - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + - GNU General Public License for more details. + - + - You should have received a copy of the GNU General Public License + - along with FuncTorrent; if not, see + -} + module MetainfoTests where import Prelude hiding (readFile) @@ -19,5 +38,12 @@ tests = hspec $ do case torrentToMetainfo fc of Left _ -> pending Right metainfo -> do - announceList metainfo `shouldNotBe` [] + announceList metainfo `shouldSatisfy` (not . null) + it "valid piece length" $ do + fc <- readFile "data/debian-7.8.0-amd64-CD-1.iso.torrent" + case torrentToMetainfo fc of + Left _ -> pending + Right metainfo -> do + let (Just info') = info metainfo + pieceLength info' `shouldBe` (524288 :: Integer)