Skip to content

Commit

Permalink
Add a quick check test for sinkParser
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Ford authored and Ben Ford committed Jan 30, 2012
1 parent c33d3a2 commit 42d8272
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions attoparsec-conduit/test/main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Test.Hspec.Monadic
import Test.Hspec.HUnit ()
import Test.Hspec.QuickCheck (prop)
import Test.HUnit
import Test.QuickCheck

import qualified Data.Attoparsec as A
import qualified Data.Attoparsec.Char8 as AC8
Expand Down Expand Up @@ -35,6 +36,8 @@ import Control.Concurrent (threadDelay, killThread)
import Control.Monad.IO.Class (liftIO)
import Control.Applicative -- (pure, (<$>), (<*>))

instance Arbitrary S.ByteString where
arbitrary = fmap S.pack arbitrary

testParseWord :: String -> A.Parser S.ByteString
testParseWord s = (AC8.string $ C8.pack s) <* AC8.space
Expand All @@ -55,3 +58,9 @@ main = hspecX $ do
y <- bsrc $$ CL.consume
return (x, y)
y @?= [C8.pack "one two"]

prop "parse first word == head" $
\inp inp2 -> not (S.null inp) ==>
let res = runST $ runExceptionT_ $ runResourceT $ CL.sourceList [inp, inp2]
$$ CA.sinkParser $ AC8.takeWhile (/=' ')
in res == C8.takeWhile (/=' ') (inp `mappend` inp2)

0 comments on commit 42d8272

Please sign in to comment.