Commit b64ec8eb authored by Mike Ledger's avatar Mike Ledger

update test suite

parent dd39cc99
......@@ -15,18 +15,19 @@ sortOnLengthDesc = sortOn (negate . T.length)
naiiveSameAsRadix :: Monad m => Bool -> Property m
naiiveSameAsRadix doCompress =
forAll $ \(alternativesS :: NonEmpty (NonEmpty Char))
(textS :: NonEmpty Char) ->
let
alternatives = sortOnLengthDesc (map T.pack (coerce alternativesS))
rtree =
if doCompress
then R.compressBy (T.concat alternatives) (R.fromFoldable alternatives)
else R.fromFoldable alternatives
text = T.pack (coerce textS)
in
parseOnly (choice (map string alternatives)) text ==
parseOnly (R.parse rtree) text
forAll $ \(alternativesS :: NonEmpty (NonEmpty Char)) ->
let
alternatives = sortOnLengthDesc (map T.pack (coerce alternativesS))
rparse
| doCompress = R.parse $! R.fromFoldable alternatives
| otherwise = case R.compressBy (T.concat alternatives) (R.fromFoldable alternatives) of
Just crt -> R.parse $! crt
Nothing -> error "could not compress radixtree!"
in forAll $ \(textS :: NonEmpty Char) ->
let text = T.pack (coerce textS)
in parseOnly (choice (map string alternatives)) text ==
parseOnly rparse text
main :: IO ()
main = defaultMain $ testGroup "radixtree"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment