X-Git-Url: https://git.rkrishnan.org/?a=blobdiff_plain;f=test%2FMetainfoTests.hs;h=86aa0ff14b5632dece355c52a2f72be23c666a2d;hb=4861358f5573fb9ed27eda0dda72dd2ba1022e84;hp=727de500e705981e0bb3c6acbd9c972a88def022;hpb=b745c1b21a64a3677b75777996c81154e916c0a5;p=functorrent.git diff --git a/test/MetainfoTests.hs b/test/MetainfoTests.hs index 727de50..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 `shouldSatisfy` (not . null) + 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)