hscdio-0.1.0.0: test/Test/Libcdio/Unit/Foreign/DeeperDance.hs
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
{-|
Description:
Copyright: (c) 2019-2021 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 James Olin Oden at
<https://bugzilla.redhat.com/show_bug.cgi?id=1321677#c3>.
-}
module Test.Libcdio.Unit.Foreign.DeeperDance (tests) where
import qualified Test.HUnit as U
import Test.HUnit ( (@?), (@?=), (~:) )
import qualified Control.Monad as M
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 "deeper-dance.cdtext"
tests :: U.Test
tests = "Foreign.Libcdio.Test.DeeperDance" ~: 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'
l <- language x
l @?= Just English
t1 <- firstTrack x
t1 @?= Just 1
tl <- lastTrack x
tl @?= Just (fromIntegral $ length titles)
t <- cdTextGet x Title Nothing
t @?= Just "Deeper Dance"
p <- cdTextGet x Performer Nothing
p @?= performer
ts <- M.forM [1 .. length titles] $ \i -> do
t' <- cdTextGet x Title . Just $ fromIntegral i
p' <- cdTextGet x Performer . Just $ fromIntegral i
return (t', p')
ts @?= zip titles (repeat performer)
performer :: Maybe String
performer = Just "James Olin Oden"
titles :: [Maybe String]
titles = map Just
[ "Deeper Dance"
, "The Hunt"
, "Harold's Dream"
, "Jazz Fusion No. 9"
, "Love's Tattoo"
, "The Day I Told Her Micheal Domhnaill Died"
, "The Fool Amongst the Keeners"
, "Love Is Not Tame"
, "Dear John and the Big Red Pickup Truck"
, "Dance Right Out of My Grave"
]