on master help sign in
Test suite
commit0aaadf5c0447937c11d1c2149221b25c4ceb5653 authorMichael <michael@snoyman.com> dateWed 25 May 2011, 14:55 (15 years ago) parentda43b5a
1 file changed+22
runtests.hs+22
runtests.hsnew file+22
@@ -0,0 +1,22 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+import Network.Wai.Handler.Launch (insideHead)
3+import Test.Hspec
4+import Test.Hspec.HUnit
5+import Data.Enumerator hiding (map)
6+import Test.HUnit
7+import qualified Data.ByteString as S
8+
9+main :: IO ()
10+main = hspec $ describe "insideHead"
11+ [ it "handles single chunks" $ helper "bar<head>foobaz" ["bar<head>baz"]
12+ , it "handles single chunks, no <head>" $ helper "barfoo" ["bar"]
13+ , it "handles whole chunks" $ helper "bar<head>foobaz" ["bar", "<head>", "baz"]
14+ , it "handles split chunks" $ helper "bar<head>foobaz" ["bar", "<he", "ad>", "baz"]
15+ , it "handles many chunks" $ helper "bar<head>foobaz1234567890" ["bar", "<he", "ad>", "baz", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
16+ , it "handles many pieces" $ helper "bar<head>foobaz" $ map S.singleton $ S.unpack "bar<head>baz"
17+ ]
18+
19+helper :: S.ByteString -> [S.ByteString] -> Assertion
20+helper res pieces = do
21+ x <- run_ $ enumList 1 pieces $$ joinI $ insideHead "foo" $$ consume
22+ S.concat x @?= res