]> git.rkrishnan.org Git - functorrent.git/blobdiff - test/BencodeTests.hs
run bencode tests as well
[functorrent.git] / test / BencodeTests.hs
index c83e9cc0dcd903078d52cb00954e2f7f277e4bfa..d8896437f9c0efc4a051b6536f94077866d8e419 100644 (file)
@@ -2,16 +2,31 @@ module BencodeTests (tests) where
 
 import FuncTorrent.Bencode (encode, decode, BVal(..))
 
-import Test.Tasty (TestTree, testGroup)
-import Test.Tasty.QuickCheck (testProperty)
+import Test.Hspec
+import Test.QuickCheck
+import Data.ByteString.Char8 (unpack, pack)
 
 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]
+tests :: IO ()
+tests = hspec $ do
+  describe "BVal tests" $ do
+    it "encode/decode bstr tests" $ do
+      property $ \s ->
+        let encoded = encode (Bstr s)
+            decoded = decode encoded
+        in Right (Bstr s) == decoded
+    it "encode/decode bint tests" $ do
+      property $ \i ->
+        let encoded = encode (Bint i)
+            decoded = decode encoded
+        in Right (Bint i) == decoded
+  -- describe "Bencode property tests" $ do
+  --   it "encode/decode" $ do
+  --     property $ \bval ->
+  --       let encoded = encode bval
+  --           decoded = decode encoded
+  --       in Right bval == decoded