on master help sign in
Tests: streamDecodeUtf8 should report undecoded bits correctly

This tests the fix for gh-70. --HG-- extra : amend_source : e3b1f68c49e88c984c17716183a91b8dcf19be23

commit7e1a00842ca1c78e860535bcf3c13100e7487096 authorBryan O'Sullivan <bos@serpentine.com> dateWed 19 Feb 2014, 13:23 (13 years ago) parentdef2960
1 file changed+7
tests/Tests/Properties.hs+7
tests/Tests/Properties.hs+7
@@ -111,6 +111,12 @@ feedChunksOf n f bs
111111 E.Some t b f' = f x
112112 in (t,b) : feedChunksOf n f' y
113113
114+t_utf8_undecoded = forAll genUnicode $ \t ->
115+ let b = E.encodeUtf8 t
116+ ls = concatMap (leftover . E.encodeUtf8 . T.singleton) . T.unpack $ t
117+ leftover = (++ [B.empty]) . init . tail . B.inits
118+ in (map snd . feedChunksOf 1 E.streamDecodeUtf8) b == ls
119+
114120data Badness = Solo | Leading | Trailing
115121 deriving (Eq, Show)
116122
@@ -837,6 +843,7 @@ tests =
837843 testProperty "t_utf8" t_utf8,
838844 testProperty "t_utf8'" t_utf8',
839845 testProperty "t_utf8_incr" t_utf8_incr,
846+ testProperty "t_utf8_undecoded" t_utf8_undecoded,
840847 testProperty "tl_utf8" tl_utf8,
841848 testProperty "tl_utf8'" tl_utf8',
842849 testProperty "t_utf16LE" t_utf16LE,