{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} {-| Description: Copyright: (c) 2019-2020 Sam May License: GPL-3.0-or-later Maintainer: ag@eitilt.life Stability: experimental Portability: portable The CDTEXT file used in this module comes via Pigeon at (warning for a /lot/ of swearing). The encoding was later manually set to ASCII. -} module Test.Libcdio.Unit.Foreign.RevolutionDays (tests) where import qualified Test.HUnit as U import Test.HUnit ( (@?), (@?=), (~:) ) import qualified Data.ByteString as BS import qualified Data.Maybe as Y import Foreign.Libcdio.CdText import Test.Libcdio.Unit.Common testFile :: FilePath testFile = dataFile "revolution-days.cdtext" tests :: U.Test tests = "Foreign.Libcdio.Test.RevolutionDays" ~: U.TestList [ parse ] parse :: U.Test parse = "Binary CDTEXT is read properly" ~: U.TestCase $ do bs <- BS.readFile testFile x' <- cdTextDataInit bs Y.isJust x' @? "Failed to read binary CdText" let Just x = x' t1 <- firstTrack x t1 @?= Just 1 tl <- lastTrack x tl @?= Just (fromIntegral $ length titles) t <- cdTextGet x Title Nothing t @?= Just "REVOLUTION DAYS" p <- cdTextGet x Performer Nothing p @?= Just "BARCLAY JAMES HARVEST FEATURING LES HOLROYD" ts <- mapM (cdTextGet x Title . Just . fromIntegral) [1 .. length titles] ts @?= titles titles :: [Maybe String] titles = map Just [ "IT'S MY LIFE" , "MISSING YOU" , "THAT WAS THEN... THIS IS NOW" , "PRELUDE" , "JANUARY MORNING" , "LOVE ON THE LINE" , "QUIERO EL SOL" , "TOTALLY COOL" , "LIFE IS FOR LIVING" , "SLEEPY SUNDAY" , "REVOLUTION DAY" , "MARLENE (from the BERLIN SUITE)" ]