aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authormichaelt <what_is_it_to_do_anything@yahoo.com>2014-01-14 22:05:12 -0500
committermichaelt <what_is_it_to_do_anything@yahoo.com>2014-01-14 22:05:12 -0500
commit3694350ac7b9c42fd64e0092a74cf0471a080058 (patch)
tree38ddadda59a3808422fc432d37b886c456adcb1d /test
parentcd4fd5dd5405ad8e324f43ee2bc81822bdece16c (diff)
downloadtext-pipes-3694350ac7b9c42fd64e0092a74cf0471a080058.tar.gz
text-pipes-3694350ac7b9c42fd64e0092a74cf0471a080058.tar.zst
text-pipes-3694350ac7b9c42fd64e0092a74cf0471a080058.zip
Use clunky Data.Text.IO when bytestring is not explicit
Diffstat (limited to 'test')
-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