From 9bb062d46ca3124fac06fd2a4c636b603e60f1cf Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org> Date: Fri, 8 Sep 2017 10:08:53 +0530 Subject: [PATCH] quickcheck: size limit randomly generated Benc structures --- functorrent.cabal | 4 +++- src/FuncTorrent/Bencode.hs | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) 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 -- 2.45.2