From: Ramakrishnan Muthukrishnan Date: Fri, 8 Sep 2017 04:38:53 +0000 (+0530) Subject: quickcheck: size limit randomly generated Benc structures X-Git-Url: https://git.rkrishnan.org/vdrive/%22news.html/simplejson/rgr-080307.php?a=commitdiff_plain;p=functorrent.git quickcheck: size limit randomly generated Benc structures --- diff --git a/functorrent.cabal b/functorrent.cabal index 50bd270..5e71ebf 100644 --- a/functorrent.cabal +++ b/functorrent.cabal @@ -81,7 +81,9 @@ test-suite functorrent-test default-language: Haskell2010 hs-source-dirs: test main-is: Main.hs - other-modules: MagneturiTests + other-modules: BencodeTests + , MagneturiTests + , MetainfoTests build-depends: base , bytestring , functorrent diff --git a/src/FuncTorrent/Bencode.hs b/src/FuncTorrent/Bencode.hs index ac62211..b55b3fe 100644 --- a/src/FuncTorrent/Bencode.hs +++ b/src/FuncTorrent/Bencode.hs @@ -59,9 +59,9 @@ instance Arbitrary BVal where , Bstr <$> arbitrary] bval n = oneof [ Bint <$> arbitrary , Bstr <$> arbitrary - , Blist <$> vectorOf n (bval (n `div` 4)) - , do keys <- vectorOf n genNonEmptyString - vals <- vectorOf n (bval (n `div` 4)) + , Blist <$> vectorOf (n `div` 2) (bval (n `div` 4)) + , do keys <- vectorOf (n `div` 2) genNonEmptyString + vals <- vectorOf (n `div` 2) (bval (n `div` 4)) return $ Bdict $ fromList $ zip keys vals ] -- getters