From: Ramakrishnan Muthukrishnan Date: Sun, 26 Apr 2015 16:34:27 +0000 (+0530) Subject: WIP: split tests into their own modules X-Git-Url: https://git.rkrishnan.org/vdrive/%5B/%5D%20/uri//%22%22?a=commitdiff_plain;h=816d5fa04e07bed4cab281b5589128948f6ed19a;p=functorrent.git WIP: split tests into their own modules To start with, the Bencode test is now in its own module. --- diff --git a/functorrent.cabal b/functorrent.cabal index b2d3c6a..05ed4b3 100644 --- a/functorrent.cabal +++ b/functorrent.cabal @@ -66,6 +66,7 @@ test-suite functorrent-test default-language: Haskell2010 hs-source-dirs: test main-is: Test.hs + other-modules: BencodeTests build-depends: base, functorrent, bytestring, diff --git a/test/BencodeTests.hs b/test/BencodeTests.hs new file mode 100644 index 0000000..c83e9cc --- /dev/null +++ b/test/BencodeTests.hs @@ -0,0 +1,17 @@ +module BencodeTests (tests) where + +import FuncTorrent.Bencode (encode, decode, BVal(..)) + +import Test.Tasty (TestTree, testGroup) +import Test.Tasty.QuickCheck (testProperty) + +propEncodeDecode :: BVal -> Bool +propEncodeDecode bval = let encoded = encode bval + decoded = decode encoded + in Right bval == decoded + +qcTests :: TestTree +qcTests = testGroup "QuickCheck tests" [ testProperty "encode/decode" propEncodeDecode ] + +tests :: TestTree +tests = testGroup "Tests" [qcTests] diff --git a/test/Test.hs b/test/Test.hs index 77a8d72..9915d97 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -8,13 +8,14 @@ import Data.Map.Strict (fromList) import Test.Tasty (TestTree, testGroup, defaultMain) import Test.Tasty.HUnit (testCase, (@?=)) -import Test.Tasty.QuickCheck (testProperty) 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 [ @@ -93,16 +94,8 @@ unitTests :: TestTree unitTests = testGroup "Unit tests" [testFile, testMkMetaInfo, testResponse1, testResponse2] -propEncodeDecode :: BVal -> Bool -propEncodeDecode bval = let encoded = encode bval - decoded = decode encoded - in Right bval == decoded - -qcTests :: TestTree -qcTests = testGroup "QuickCheck tests" [ testProperty "encode/decode" propEncodeDecode ] - tests :: TestTree -tests = testGroup "Tests" [unitTests, qcTests] +tests = testGroup "Tests" [unitTests, BencodeTests.tests] main :: IO () main = defaultMain tests