]> git.rkrishnan.org Git - functorrent.git/blob - test/BencodeTests.hs
004234d53d3224690b0a08fee293f5c32584db15
[functorrent.git] / test / BencodeTests.hs
1 module BencodeTests (tests) where
2
3 import FuncTorrent.Bencode (encode, decode, BVal(..))
4
5 import Test.Hspec
6 import Test.QuickCheck
7 import Data.ByteString.Char8 (unpack, pack)
8
9 propEncodeDecode :: BVal -> Bool
10 propEncodeDecode bval = let encoded = encode bval
11                             decoded = decode encoded
12                         in Right bval == decoded
13
14 tests :: IO ()
15 tests = hspec $ do
16   describe "BVal tests" $ do
17     it "encode/decode" $ do
18       property $ \bval ->
19         let encoded = encode bval
20             decoded = decode encoded
21         in Right bval == decoded