~ubuntu-branches/ubuntu/trusty/haskell-text/trusty

« back to all changes in this revision

Viewing changes to tests/Tests/Regressions.hs

  • Committer: Package Import Robot
  • Author(s): Joachim Breitner
  • Date: 2013-05-27 15:29:56 UTC
  • mfrom: (4.2.2 sid)
  • Revision ID: package-import@ubuntu.com-20130527152956-2mj3ud1ahuv386b1
Tags: 0.11.3.1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
import Control.Exception (SomeException, handle)
10
10
import System.IO
11
 
import Test.HUnit (assertFailure)
 
11
import Test.HUnit (assertBool, assertFailure)
12
12
import qualified Data.ByteString as B
 
13
import Data.ByteString.Char8 ()
13
14
import qualified Data.ByteString.Lazy as LB
14
15
import qualified Data.Text as T
 
16
import qualified Data.Text.Encoding as TE
15
17
import qualified Data.Text.IO as T
16
18
import qualified Data.Text.Lazy as LT
17
19
import qualified Data.Text.Lazy.Encoding as LE
49
51
    power | maxBound == (2147483647::Int) = 28
50
52
          | otherwise                     = 60 :: Int
51
53
 
 
54
-- Reported by John Millikin: a UTF-8 decode error handler could
 
55
-- return a bogus substitution character, which we would write without
 
56
-- checking.
 
57
utf8_decode_unsafe :: IO ()
 
58
utf8_decode_unsafe = do
 
59
  let t = TE.decodeUtf8With (\_ _ -> Just '\xdc00') "\x80"
 
60
  assertBool "broken error recovery shouldn't break us" (t == "\xfffd")
 
61
 
52
62
tests :: F.Test
53
63
tests = F.testGroup "Regressions"
54
64
    [ F.testCase "hGetContents_crash" hGetContents_crash
55
65
    , F.testCase "lazy_encode_crash" lazy_encode_crash
56
66
    , F.testCase "replicate_crash" replicate_crash
 
67
    , F.testCase "utf8_decode_unsafe" utf8_decode_unsafe
57
68
    ]