-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.hs
More file actions
37 lines (28 loc) · 1.1 KB
/
test.hs
File metadata and controls
37 lines (28 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{-# LANGUAGE OverloadedStrings #-}
import Functions
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as LB
import System.IO (BufferMode(..), hSetBuffering, stdout, stderr)
import Hedgehog
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range
stringToByteString :: Property
stringToByteString = property $ do
xs <- forAll $ Gen.string (Range.linear 0 10000) Gen.unicode
(oldDecodeUtf8 . (oldEncodeUtf8 :: String -> B.ByteString)) xs === (newDecodeUtf8 . (newEncodeUtf8 :: String -> B.ByteString)) xs
stringToLazyByteString :: Property
stringToLazyByteString = property $ do
xs <- forAll $ Gen.string (Range.linear 0 10000) Gen.unicode
(oldDecodeUtf8 . (oldEncodeUtf8 :: String -> LB.ByteString)) xs === (newDecodeUtf8 . (newEncodeUtf8 :: String -> LB.ByteString)) xs
tests :: IO Bool
tests =
checkSequential $ Group "This module" [
("strict", stringToByteString),
("lazy", stringToLazyByteString)
]
main :: IO ()
main = do
hSetBuffering stdout LineBuffering
hSetBuffering stderr LineBuffering
_ <- tests
return ()