on master help sign in
Test the lazy UTF-8 code.
commite2d6e1646e911d1d571580ca8e18d408cc76ac30 authorBryan O'Sullivan <bos@serpentine.com> dateTue 15 Mar 2011, 20:42 (16 years ago) parentca0c205
1 file changed+10−1
tests/Properties.hs+10−1
tests/Properties.hs+10−1
@@ -78,7 +78,9 @@ t_ascii t = E.decodeASCII (E.encodeUtf8 a) == a
7878tl_ascii t = EL.decodeASCII (EL.encodeUtf8 a) == a
7979 where a = TL.map (\c -> chr (ord c `mod` 128)) t
8080t_utf8 = forAll genUnicode $ (E.decodeUtf8 . E.encodeUtf8) `eq` id
81+t_utf8' = forAll genUnicode $ (E.decodeUtf8' . E.encodeUtf8) `eq` (id . Right)
8182tl_utf8 = forAll genUnicode $ (EL.decodeUtf8 . EL.encodeUtf8) `eq` id
83+tl_utf8' = forAll genUnicode $ (EL.decodeUtf8' . EL.encodeUtf8) `eq` (id . Right)
8284t_utf16LE = forAll genUnicode $ (E.decodeUtf16LE . E.encodeUtf16LE) `eq` id
8385tl_utf16LE = forAll genUnicode $ (EL.decodeUtf16LE . EL.encodeUtf16LE) `eq` id
8486t_utf16BE = forAll genUnicode $ (E.decodeUtf16BE . E.encodeUtf16BE) `eq` id
@@ -110,6 +112,10 @@ t_utf8_err (DE _ de) bs = monadicIO $ do
110112 Left err -> assert $ length (show err) >= 0
111113 Right n -> assert $ n >= 0
112114
115+t_utf8_err' bs = monadicIO . assert $ case E.decodeUtf8' bs of
116+ Left err -> length (show err) >= 0
117+ Right t -> T.length t >= 0
118+
113119class Stringy s where
114120 packS :: String -> s
115121 unpackS :: s -> String
@@ -831,7 +837,9 @@ tests = [
831837 testProperty "t_ascii" t_ascii,
832838 testProperty "tl_ascii" tl_ascii,
833839 testProperty "t_utf8" t_utf8,
840+ testProperty "t_utf8'" t_utf8',
834841 testProperty "tl_utf8" tl_utf8,
842+ testProperty "tl_utf8'" tl_utf8',
835843 testProperty "t_utf16LE" t_utf16LE,
836844 testProperty "tl_utf16LE" tl_utf16LE,
837845 testProperty "t_utf16BE" t_utf16BE,
@@ -841,7 +849,8 @@ tests = [
841849 testProperty "t_utf32BE" t_utf32BE,
842850 testProperty "tl_utf32BE" tl_utf32BE,
843851 testGroup "errors" [
844− testProperty "t_utf8_err" t_utf8_err
852+ testProperty "t_utf8_err" t_utf8_err,
853+ testProperty "t_utf8_err'" t_utf8_err'
845854 ]
846855 ],
847856