]> git.rkrishnan.org Git - functorrent.git/commitdiff
WIP: split tests into their own modules
authorRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sun, 26 Apr 2015 16:34:27 +0000 (22:04 +0530)
committerRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sun, 26 Apr 2015 16:34:27 +0000 (22:04 +0530)
To start with, the Bencode test is now in its own module.

functorrent.cabal
test/BencodeTests.hs [new file with mode: 0644]
test/Test.hs

index b2d3c6a110a65befa372f4a45104a518b1cf2b95..05ed4b3aa8286c403b2611126c15195f007636e6 100644 (file)
@@ -66,6 +66,7 @@ test-suite functorrent-test
   default-language:  Haskell2010
   hs-source-dirs:    test
   main-is:           Test.hs
   default-language:  Haskell2010
   hs-source-dirs:    test
   main-is:           Test.hs
+  other-modules:     BencodeTests
   build-depends:     base,
                      functorrent,
                      bytestring,
   build-depends:     base,
                      functorrent,
                      bytestring,
diff --git a/test/BencodeTests.hs b/test/BencodeTests.hs
new file mode 100644 (file)
index 0000000..c83e9cc
--- /dev/null
@@ -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]
index 77a8d72de8147c32af55e1702ee4e1e6adcd299a..9915d977133dde2d0f23dbcd3bfa67361db2130a 100644 (file)
@@ -8,13 +8,14 @@ import Data.Map.Strict (fromList)
 
 import Test.Tasty (TestTree, testGroup, defaultMain)
 import Test.Tasty.HUnit (testCase, (@?=))
 
 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 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 [
 -- Parsed .torrent file
 file :: BVal
 file = Bdict (fromList [
@@ -93,16 +94,8 @@ unitTests :: TestTree
 unitTests = testGroup "Unit tests" [testFile, testMkMetaInfo, testResponse1,
                                             testResponse2]
 
 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 :: TestTree
-tests = testGroup "Tests" [unitTests, qcTests]
+tests = testGroup "Tests" [unitTests, BencodeTests.tests]
 
 main :: IO ()
 main = defaultMain tests
 
 main :: IO ()
 main = defaultMain tests