1. cabal sandbox init
2. wget http://www.stackage.org/lts/cabal.config
-3. cabal install --only-dependencies
+3. cabal install --only-dependencies --enable-tests
4. cabal build # binaries in ./dist/built/functorrent/*
Goals
--- /dev/null
+d8:intervali900e5:peers300:U\19ÉeÈÕ%;\1cìVÎL\15\95+Ê\9a\1f·!Í©ËÕÒxVkXÕïØÍ\e\ 2[À£\98.:>ÒðA\eWTúg¡\e%XÃñÀÈÕX¥=ß\1aáV\9dêóè¿Õ)\89òÈÕ[
+T÷]@8ù·\eoÊ>\10Gê\19\1f+~záØD©\85HÄ.ß\87a±å½\ 5¦]vûËÈ\94m\8dÈÕmâì \9cN:\8b\9aY"¼ô/º\9aÛËVÌoÌ»Pn(b\e\ 6D»\8eÙãðGs\8b´öYF©#ÈÕ¹\ 3\87º*\89XÆàÊÈÕ·\9dAÙ#ÛWû½\96¶XWrÊ®0i]:\ 5\10ÈÓYf E'<^\9f\13Þ=§_\1c1°åªÙr:\87\1aáO\8d¢&\8bÞ\88©2HÖ\8f»C¼\97ÈÕOoÚ2Ñ\84>K\89\81ÈÕ\ eÌ\14\9c-PO\8d¢"_ÓR\90À\aöèÔ"ç
+PÌ_áöÝÈÕ|)ífa*6:peers60:e
\ No newline at end of file
hs-source-dirs: src
ghc-options: -Wall -fwarn-incomplete-patterns
default-language: Haskell2010
- build-depends: base,
- HTTP,
+ build-depends: HTTP,
+ HUnit,
+ base,
base16-bytestring,
binary,
bytestring,
cryptohash,
doctest,
network-uri,
- parsec
+ parsec,
+ tasty,
+ tasty-hunit
executable functorrent
main-is: Main.hs
hs-source-dirs: src
ghc-options: -Wall -fwarn-incomplete-patterns
default-language: Haskell2010
- build-depends: base,
- HTTP,
+ build-depends: HTTP,
+ base,
base16-bytestring,
binary,
bytestring,
doctest,
network-uri,
parsec
+
+test-suite lisper-test
+ type: exitcode-stdio-1.0
+ default-language: Haskell2010
+ hs-source-dirs: test
+ main-is: Test.hs
+ build-depends: HUnit,
+ base,
+ bytestring,
+ containers,
+ functorrent,
+ tasty,
+ tasty-hunit
--- /dev/null
+{-# LANGUAGE OverloadedStrings #-}
+module Main where
+
+import Prelude hiding (readFile)
+import Data.ByteString.Char8 (readFile)
+import Data.Map.Strict (fromList)
+
+import Test.Tasty
+import Test.Tasty.HUnit
+
+import FuncTorrent.Bencode (decode, BVal(..))
+
+
+
+debian :: BVal
+debian = Bdict (fromList [
+ (Bstr "interval", Bint 900),
+ (Bstr "peers", Bstr "U\EM\201e\200\213%;\FS\236V\206L\NAK\149+\202\154\US\183!\205\169\203\213\210xVkX\213\239\216\205\ESC\STX[\192\163\152.:>\210\240A\ESCWT\250g\161\ESC%X\195\241\192\200\213X\165=\223\SUB\225V\157\234\243\232\191\213)\137\242\200\213[\nT\195\183]@8\249\183\ESCo\202>\DLEG\234\EM\US+~z\225\216D\169\133H\196.\223\135a\177\229\189\ENQ\166]v\251\203\200\148m\141\200\213m\226\236\160\173\156N:\139\154Y\"\188\244/\186\154\219\203V\204o\204\187Pn(b\ESC\ACKD\187\142\217\227\240Gs\139\180\246YF\169#\173\200\213\185\ETX\135\186*\137X\198\224\202\200\213\183\157A\217#\219W\251\189\150\182XWr\202\174\&0i]:\ENQ\DLE\200\211Yf\tE'<^\159\DC3\222=\167_\FS1\176\229\170\217r:\135\SUB\225O\141\162&\139\222\136\169\&2H\214\143\187C\188\151\200\213Oo\218\&2\209\132>K\137\129\200\213\SO\204\DC4\156-PO\141\162\"_\211R\144\192\a\246\232\212\"\231\nP\204_\225\246\221\200\213|)\237fa*"),
+ (Bstr "peers6", Bstr "")
+ ])
+
+testSimple :: TestTree
+testSimple = testCase "Should parse regular torrent files" $ do
+ str <- readFile "./data/debian-7.8.0-amd64-CD-1.iso.cache"
+ case decode str of
+ Right expected -> expected @?= debian
+ Left _ -> error "Failed parsing test file"
+
+unitTests :: TestTree
+unitTests = testGroup "Unit tests" [testSimple]
+
+tests :: TestTree
+tests = testGroup "Tests" [unitTests]
+
+main :: IO ()
+main = defaultMain tests