aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/Test.hs
diff options
context:
space:
mode:
Diffstat (limited to 'test/Test.hs')
-rw-r--r--test/Test.hs17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/Test.hs b/test/Test.hs
index f2bf17b..373bafb 100644
--- a/test/Test.hs
+++ b/test/Test.hs
@@ -27,11 +27,11 @@ import qualified Pipes as P
27main :: IO () 27main :: IO ()
28main = defaultMain [tests] 28main = defaultMain [tests]
29-- >>> :main -a 10000 29-- >>> :main -a 10000
30
31tests = testGroup "stream_decode" [ 30tests = testGroup "stream_decode" [
32 -- testProperty "t_utf8_incr_valid" t_utf8_incr_valid, 31 -- testProperty "t_utf8_incr_valid" t_utf8_incr_valid,
33 testProperty "t_utf8_incr_mixed" t_utf8_incr_mixed , 32 testProperty "t_utf8_incr_mixed" t_utf8_incr_mixed ,
34 testProperty "t_utf8_incr_pipe" t_utf8_incr_pipe] 33 testProperty "t_utf8_incr_pipe" t_utf8_incr_pipe,
34 testProperty "t_utf8_dec_some" t_utf8_dec_some]
35 35
36t_utf8_incr_valid = do 36t_utf8_incr_valid = do
37 Positive n <- arbitrary 37 Positive n <- arbitrary
@@ -82,6 +82,19 @@ t_utf8_incr_pipe = do
82 chunk n bs = let (a,b) = B.splitAt n bs in if B.null a then [] else a : chunk n b 82 chunk n bs = let (a,b) = B.splitAt n bs in if B.null a then [] else a : chunk n b
83 appendBytes txt bts = E.encodeUtf8 txt <> B.pack bts ; (<>) = B.append 83 appendBytes txt bts = E.encodeUtf8 txt <> B.pack bts ; (<>) = B.append
84 84
85--
86t_utf8_dec_some = do
87 Positive m <- arbitrary
88 txt <- genUnicode
89 let bytesLength = mod 10 m :: Int
90 forAll (vector bytesLength) $
91 (roundtrip . appendBytes txt)
92 `eq`
93 appendBytes txt
94 where
95 roundtrip bs = case PE.decodeSomeUtf8 bs of
96 (txt,bys) -> E.encodeUtf8 txt <> bys
97 appendBytes txt bts = E.encodeUtf8 txt <> B.pack bts ; (<>) = B.append
85 98
86 99
87 100