]> git.rkrishnan.org Git - functorrent.git/blobdiff - test/Test.hs
WIP: split tests into their own modules
[functorrent.git] / test / Test.hs
index fb6c768e3fe45c58884106f3c02ef5c9927c84d8..9915d977133dde2d0f23dbcd3bfa67361db2130a 100644 (file)
@@ -6,14 +6,16 @@ import Prelude hiding (readFile)
 import Data.ByteString (ByteString, readFile)
 import Data.Map.Strict (fromList)
 
-import Test.Tasty
-import Test.Tasty.HUnit
+import Test.Tasty (TestTree, testGroup, defaultMain)
+import Test.Tasty.HUnit (testCase, (@?=))
 
-import FuncTorrent.Bencode (decode, BVal(..))
+import FuncTorrent.Bencode (encode, decode, BVal(..))
 import FuncTorrent.Metainfo (Info(..), Metainfo(..), mkMetaInfo)
 import FuncTorrent.Peer (Peer(..))
 import FuncTorrent.Tracker
 
+import qualified BencodeTests
+
 -- Parsed .torrent file
 file :: BVal
 file = Bdict (fromList [
@@ -39,12 +41,12 @@ hello = Metainfo {
             lengthInBytes = 12,
             md5sum = Nothing
           },
-          infoHash = "\249\SYN\145=\129\182\205\\\181v0\144\154\EM\150f\152\221]}",
           announceList = ["http://9.rarbg.com:2710/announce"],
           creationDate = Just 1428717851,
           comment = Just "hello world",
           createdBy = Just "Jaseem Abid",
-          encoding = Just "UTF-8"
+          encoding = Just "UTF-8",
+          infoHash = "\205CX(;\163<?TWS\175\CAND\222\253\250\214\136\EOT"
         }
 
 testFile :: TestTree
@@ -93,7 +95,7 @@ unitTests = testGroup "Unit tests" [testFile, testMkMetaInfo, testResponse1,
                                             testResponse2]
 
 tests :: TestTree
-tests = testGroup "Tests" [unitTests]
+tests = testGroup "Tests" [unitTests, BencodeTests.tests]
 
 main :: IO ()
 main = defaultMain tests