{-| Description: Copyright: (c) 2020 Sam May License: GPL-3.0-or-later Maintainer: ag@eitilt.life Stability: experimental Portability: portable -} module Sound.Libcdio.CdText.Test.Classes ( laws , genCdTextError , genCdTextErrorType , genInfo ) where import qualified Hedgehog as H import qualified Hedgehog.Gen as H.G import qualified Hedgehog.Range as H.R import qualified Hedgehog.Classes as H.C import Sound.Libcdio.Read.CdText import Foreign.Libcdio.CdText.Test.Classes hiding ( laws ) import Test.Libcdio.Property.Common laws :: [LawsGroup] laws = [ ("Info", map (\f -> f genInfo) [ H.C.eqLaws , H.C.showLaws , H.C.showReadLaws ] ), ("CdTextErrrorType", map (\f -> f genCdTextErrorType) [ H.C.eqLaws , H.C.showLaws , H.C.showReadLaws ] ), ("CdTextErrror", map (\f -> f genCdTextError) [ H.C.eqLaws , H.C.showLaws , H.C.showReadLaws ] )] genCdTextErrorType :: H.Gen CdTextErrorType genCdTextErrorType = H.G.choice [ InvalidBlock <$> H.G.word H.R.linearBounded , LanguageNotFound <$> genLanguage , H.G.constant BadBinaryRead , FreeformCdTextError <$> genSample ] genCdTextError :: H.Gen CdTextError genCdTextError = CdTextError <$> genCdTextErrorType <*> genSample genInfo :: H.Gen Info genInfo = do t <- H.G.maybe genSample p <- H.G.maybe genSample s <- H.G.maybe genSample c <- H.G.maybe genSample a <- H.G.maybe genSample m <- H.G.maybe genSample o <- H.G.maybe genSample return $ Info { title = t , performer = p , songwriter = s , composer = c , arranger = a , message = m , code = o }