]> git.rkrishnan.org Git - functorrent.git/blobdiff - test/MetainfoTests.hs
tests: add license boilerplate
[functorrent.git] / test / MetainfoTests.hs
index 824bb64ee1d50568e1ba81c84ced0269ab51516d..86aa0ff14b5632dece355c52a2f72be23c666a2d 100644 (file)
@@ -1,5 +1,24 @@
 -- | Tests for Metainfo module
 
+{-
+ - Copyright (C) 2015-2016 Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
+ -
+ - 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 <http://www.gnu.org/licenses/>
+ -}
+
 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)