diff options
author | michaelt <what_is_it_to_do_anything@yahoo.com> | 2013-12-26 11:38:06 -0500 |
---|---|---|
committer | michaelt <what_is_it_to_do_anything@yahoo.com> | 2013-12-26 11:38:06 -0500 |
commit | 1b4f53266cadfbd54f8198908424b4890fb1755f (patch) | |
tree | ce23e27313e5f1bc0c01c2b4e1462496cc2294b3 /test | |
parent | c9d1c945a4343d756533b85060c35c04be0c8b02 (diff) | |
download | text-pipes-1b4f53266cadfbd54f8198908424b4890fb1755f.tar.gz text-pipes-1b4f53266cadfbd54f8198908424b4890fb1755f.tar.zst text-pipes-1b4f53266cadfbd54f8198908424b4890fb1755f.zip |
missing case in decodeUtf8
Diffstat (limited to 'test')
-rw-r--r-- | test/Test.hs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/test/Test.hs b/test/Test.hs index 66351d1..53dca6a 100644 --- a/test/Test.hs +++ b/test/Test.hs | |||
@@ -23,17 +23,16 @@ import qualified Pipes.Text.Internal as PE | |||
23 | import qualified Pipes.Text as TP | 23 | import qualified Pipes.Text as TP |
24 | import qualified Pipes.ByteString as BP | 24 | import qualified Pipes.ByteString as BP |
25 | import qualified Pipes as P | 25 | import qualified Pipes as P |
26 | |||
27 | |||
28 | import Debug.Trace | 26 | import Debug.Trace |
27 | |||
29 | main :: IO () | 28 | main :: IO () |
30 | main = defaultMain [tests] | 29 | main = defaultMain [tests] |
31 | -- >>> :main -a 10000 | 30 | -- >>> :main -a 10000 |
32 | 31 | ||
33 | tests = testGroup "stream_decode" [ | 32 | tests = testGroup "stream_decode" [ |
34 | -- testProperty "t_utf8_incr_valid" t_utf8_incr_valid, | 33 | -- testProperty "t_utf8_incr_valid" t_utf8_incr_valid, |
35 | testProperty "t_utf8_incr_mixed" t_utf8_incr_mixed, | 34 | -- testProperty "t_utf8_incr_mixed" t_utf8_incr_mixed ] -- , |
36 | testProperty "t_utf8_incr_pipe" t_utf8_incr_pipe] | 35 | testProperty "t_utf8_incr_pipe" t_utf8_incr_pipe] |
37 | 36 | ||
38 | t_utf8_incr_valid = do | 37 | t_utf8_incr_valid = do |
39 | Positive n <- arbitrary | 38 | Positive n <- arbitrary |
@@ -68,23 +67,19 @@ t_utf8_incr_mixed = do | |||
68 | chunk n bs = let (a,b) = B.splitAt n bs in if B.null a then [] else a : chunk n b | 67 | chunk n bs = let (a,b) = B.splitAt n bs in if B.null a then [] else a : chunk n b |
69 | appendBytes txt bts = E.encodeUtf8 txt <> B.pack bts ; (<>) = B.append | 68 | appendBytes txt bts = E.encodeUtf8 txt <> B.pack bts ; (<>) = B.append |
70 | 69 | ||
71 | |||
72 | |||
73 | |||
74 | t_utf8_incr_pipe = do | 70 | t_utf8_incr_pipe = do |
75 | Positive m <- arbitrary | 71 | Positive m <- arbitrary |
76 | Positive n <- arbitrary | 72 | Positive n <- arbitrary |
77 | txt <- genUnicode | 73 | txt <- genUnicode |
78 | let chunkSize = mod n 7 + 1 | 74 | let chunkSize = mod n 7 + 1 |
79 | bytesLength = mod 20 m | 75 | bytesLength = mod 3 m |
80 | forAll (vector bytesLength) $ | 76 | forAll (vector bytesLength) $ |
81 | (BL.toStrict . BP.toLazy . roundtrip . P.each . chunk chunkSize . appendBytes txt) | 77 | (BL.toStrict . BP.toLazy . roundtrip . P.each . chunk chunkSize . appendBytes txt) |
82 | `eq` | 78 | `eq` |
83 | appendBytes txt | 79 | appendBytes txt |
84 | where | 80 | where |
85 | roundtrip :: Monad m => P.Producer B.ByteString m r -> P.Producer B.ByteString m r | 81 | roundtrip :: Monad m => P.Producer B.ByteString m r -> P.Producer B.ByteString m r |
86 | roundtrip p = do pbs <- TP.decodeUtf8 p P.>-> TP.encodeUtf8 | 82 | roundtrip p = join (TP.decodeUtf8 p P.>-> TP.encodeUtf8) |
87 | pbs | ||
88 | chunk n bs = let (a,b) = B.splitAt n bs in if B.null a then [] else a : chunk n b | 83 | chunk n bs = let (a,b) = B.splitAt n bs in if B.null a then [] else a : chunk n b |
89 | appendBytes txt bts = E.encodeUtf8 txt <> B.pack bts ; (<>) = B.append | 84 | appendBytes txt bts = E.encodeUtf8 txt <> B.pack bts ; (<>) = B.append |
90 | 85 | ||