hscdio-0.1.0.0: test/Data/Text/Encoding/MsJIS/Test/Classes.hs
{-|
Description:
Copyright: (c) 2020-2021 Sam May
License: GPL-3.0-or-later
Maintainer: ag@eitilt.life
Stability: experimental
Portability: portable
-}
module Data.Text.Encoding.MsJIS.Test.Classes
( laws
, genJISChar
, genDecodeError
, genEncodeError
) where
import qualified Hedgehog as H
import qualified Hedgehog.Gen as H.G
import qualified Hedgehog.Classes as H.C
import qualified Data.Text as T
import Data.Text.Encoding.MsJIS
import Test.Libcdio.Property.Common
laws :: [LawsGroup]
laws =
[ ("JISChar", map (\f -> f genJISChar)
[ H.C.eqLaws
, ordLaws'
, H.C.showLaws
, H.C.showReadLaws
, H.C.boundedEnumLaws
]
), ("JISDecodeError", map (\f -> f genDecodeError)
[ H.C.eqLaws
, H.C.showLaws
, H.C.showReadLaws
]
), ("JISEncodeError", map (\f -> f genEncodeError)
[ H.C.eqLaws
, H.C.showLaws
, H.C.showReadLaws
]
)]
genJISChar :: H.Gen JISChar
genJISChar = H.G.enumBounded
genDecodeError :: H.Gen JISDecodeError
genDecodeError = do
s <- genSample
c <- H.G.maybe genJISChar
return $ JISDecodeError (T.unpack s) c
genEncodeError :: H.Gen JISEncodeError
genEncodeError = do
s <- genSample
c <- H.G.maybe H.G.unicode
return $ JISEncodeError (T.unpack s) c