From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Wed, 26 Jul 2017 13:37:21 +0000 (+0530)
Subject: metainfotest: add a piecelength test
X-Git-Url: https://git.rkrishnan.org/%5B/frontends//%22news.html/%22?a=commitdiff_plain;h=54c316329d2eac3f31577b28d18433decfd84a7f;p=functorrent.git

metainfotest: add a piecelength test
---

diff --git a/test/MetainfoTests.hs b/test/MetainfoTests.hs
index 727de50..f27486f 100644
--- a/test/MetainfoTests.hs
+++ b/test/MetainfoTests.hs
@@ -19,5 +19,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)