hscdio-0.1.0.0: test/Test/Libcdio/Unit/Sound/CarolusRex.hs
{-|
Description: Tests of multi-block CDTEXT in the Sound interface.
Copyright: (c) 2020-2021 Sam May
License: GPL-3.0-or-later
Maintainer: ag@eitilt.life
Stability: experimental
Portability: portable
The CDTEXT file used in this module was generated using the tool written by
Pigeon at <https://pigeonsnest.co.uk/stuff/cdtext.html> (warning for a /lot/ of
swearing). The encoding was later manually set to ASCII.
-}
module Test.Libcdio.Unit.Sound.CarolusRex (tests) where
import qualified Test.HUnit as U
import Test.HUnit ( (@?=), (~:) )
import qualified Data.ByteString as BS
import qualified Data.Maybe as Y
import qualified Data.Text as T
import Sound.Libcdio.Read.CdText
import Test.Libcdio.Unit.Sound.Common
testFile :: FilePath
testFile = dataFile "carolus-rex.cdtext"
tests :: U.Test
tests = "Sound.Libcdio.Test.CarolusRex" ~: U.TestList
[ binary
]
binary :: U.Test
binary = "Binary CDTEXT is read properly" ~: U.TestCase $ do
bs <- BS.readFile testFile
x <- parseCdText bs . withAll $ do
l <- language
a <- checkLanguage $ zip langs [infoEnglish, infoSwedish]
return (l, a)
either (const $ U.assertFailure "Could not parse binary data") runAssertions x
runAssertions :: [Maybe (Language, U.Assertion)] -> IO ()
runAssertions xs = do
let (ls, as) = unzip $ Y.catMaybes xs
ls @?= langs
sequence_ as
langs :: [Language]
langs = [English, Swedish]
infoEnglish :: [Info]
infoEnglish = emptyInfo
{ title = Just $ T.pack "Carolus Rex"
, performer = Just $ T.pack "Sabaton"
} : map (\t -> emptyInfo { title = Just $ T.pack t })
[ "Dominium maris Baltici"
, "The Lion from the North"
, "Gott mit uns"
, "A Lifetime of War"
, "1648"
, "The Carolean's Prayer"
, "Carolus Rex"
, "Killing Ground"
, "Poltava"
, "Long Live the King"
, "Ruina Imperii"
]
infoSwedish :: [Info]
infoSwedish = emptyInfo
{ title = Just $ T.pack "Carolus Rex"
, performer = Just $ T.pack "Sabaton"
} : map (\t -> emptyInfo { title = Just $ T.pack t })
[ "Dominium maris Baltici"
, "Lejonet fraan Norden"
, "Gott mit uns"
, "En Livstid i krig"
, "1648"
, "Karolinens bo:n"
, "Carolus Rex"
, "Ett slag fa:rgat ro:tt"
, "Poltava"
, "Konungens likfa:rd"
, "Ruina Imperii"
]