module Algorithms.DFA.Test.KMP where
import Algorithms.DFA.KMP ((==!))
import Test.QuickCheck
import Data.List
import Control.Monad
import Debug.Trace
rif :: Eq a => [a] -> [a] -> Bool
rif p s = any (isPrefixOf p) $ tails s
data Rif a = Rif [a] [a] Bool deriving Show
instance (Show a, Eq a, Arbitrary a) => Arbitrary (Rif a) where
arbitrary = do
n <- choose (1,10)
p <- vectorOf n arbitrary
m <- choose (0,4*n)
s <- vectorOf m arbitrary
return $ Rif p s (rif p s)
test :: Rif Bool -> Bool
test (Rif p s r) = p ==! s == r