]> git.rkrishnan.org Git - functorrent.git/blobdiff - test/BencodeTests.hs
tests: add license boilerplate
[functorrent.git] / test / BencodeTests.hs
index c83e9cc0dcd903078d52cb00954e2f7f277e4bfa..6949e7958db4649a0216f5a41cba05fffdd215bc 100644 (file)
@@ -1,17 +1,40 @@
+{-
+ - Copyright (C) 2015-2016 Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
+ -
+ - This file is part of FuncTorrent.
+ -
+ - FuncTorrent is free software; you can redistribute it and/or modify
+ - it under the terms of the GNU General Public License as published by
+ - the Free Software Foundation; either version 3 of the License, or
+ - (at your option) any later version.
+ -
+ - FuncTorrent is distributed in the hope that it will be useful,
+ - but WITHOUT ANY WARRANTY; without even the implied warranty of
+ - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ - GNU General Public License for more details.
+ -
+ - You should have received a copy of the GNU General Public License
+ - along with FuncTorrent; if not,  see <http://www.gnu.org/licenses/>
+ -}
+
 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" $ do
+      property $ \bval ->
+        let encoded = encode bval
+            decoded = decode encoded
+        in Right bval == decoded