aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authormichaelt <what_is_it_to_do_anything@yahoo.com>2014-01-25 21:42:54 -0500
committermichaelt <what_is_it_to_do_anything@yahoo.com>2014-01-25 21:42:54 -0500
commit64e03122e6ecc4898cb1b193cdcf3b26d3e71b14 (patch)
tree63b707950efcd92db00ac6979b792b9f30627e06 /test
parent7ded3267a3b62ff896ea22262549f9511273c45f (diff)
downloadtext-pipes-64e03122e6ecc4898cb1b193cdcf3b26d3e71b14.tar.gz
text-pipes-64e03122e6ecc4898cb1b193cdcf3b26d3e71b14.tar.zst
text-pipes-64e03122e6ecc4898cb1b193cdcf3b26d3e71b14.zip
renamed fold foldChars and began updating documentation
Diffstat (limited to 'test')
-rw-r--r--test/Test.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/Test.hs b/test/Test.hs
index 373bafb..7832f76 100644
--- a/test/Test.hs
+++ b/test/Test.hs
@@ -31,6 +31,7 @@ tests = testGroup "stream_decode" [
31 -- testProperty "t_utf8_incr_valid" t_utf8_incr_valid, 31 -- testProperty "t_utf8_incr_valid" t_utf8_incr_valid,
32 testProperty "t_utf8_incr_mixed" t_utf8_incr_mixed , 32 testProperty "t_utf8_incr_mixed" t_utf8_incr_mixed ,
33 testProperty "t_utf8_incr_pipe" t_utf8_incr_pipe, 33 testProperty "t_utf8_incr_pipe" t_utf8_incr_pipe,
34 testProperty "t_utf8_incr_decoding" t_utf8_incr_decoding,
34 testProperty "t_utf8_dec_some" t_utf8_dec_some] 35 testProperty "t_utf8_dec_some" t_utf8_dec_some]
35 36
36t_utf8_incr_valid = do 37t_utf8_incr_valid = do
@@ -83,6 +84,22 @@ t_utf8_incr_pipe = do
83 appendBytes txt bts = E.encodeUtf8 txt <> B.pack bts ; (<>) = B.append 84 appendBytes txt bts = E.encodeUtf8 txt <> B.pack bts ; (<>) = B.append
84 85
85-- 86--
87t_utf8_incr_decoding = do
88 Positive m <- arbitrary
89 Positive n <- arbitrary
90 txt <- genUnicode
91 let chunkSize = mod n 7 + 1
92 bytesLength = mod 10 m
93 forAll (vector bytesLength) $
94 (BL.toStrict . BP.toLazy . roundtrip . P.each . chunk chunkSize . appendBytes txt)
95 `eq`
96 appendBytes txt
97 where
98 roundtrip :: Monad m => P.Producer B.ByteString m r -> P.Producer B.ByteString m r
99 roundtrip p = join (TP.decode utf8_start p P.>-> TP.encodeUtf8)
100 chunk n bs = let (a,b) = B.splitAt n bs in if B.null a then [] else a : chunk n b
101 appendBytes txt bts = E.encodeUtf8 txt <> B.pack bts ; (<>) = B.append
102 utf8_start = PE.Some T.empty B.empty (PE.codecDecode PE.utf8)
86t_utf8_dec_some = do 103t_utf8_dec_some = do
87 Positive m <- arbitrary 104 Positive m <- arbitrary
88 txt <- genUnicode 105 txt <- genUnicode