{-| Description: Copyright: (c) 2019-2021 Sam May License: GPL-3.0-or-later Maintainer: ag@eitilt.life Stability: experimental Portability: portable -} module Test.Libcdio.Upstream.Foreign.CdrDao ( tests , goodToc , badToc ) where import qualified Test.HUnit as U import Test.HUnit ( (@?), (~:) ) import qualified System.Directory as D import Foreign.Libcdio.Device import Test.Libcdio.Upstream.Foreign.Common tests :: U.Test tests = "Foreign.Libcdio.Test.CdrDao" ~: U.TestList [ parse , open ] parse :: U.Test parse = "Distinguish valid and invalid TOC files" ~: U.TestList (map good goodToc ++ map bad badToc) where good = tocTest id "is not recognized as a TOC file" bad = tocTest not "should not be recognized as a TOC file" tocTest t s f = U.TestCase . D.withCurrentDirectory dataDir $ fmap t (isToc f) @? "'" ++ f ++ "' " ++ s goodToc :: [FilePath] goodToc = [ "cdtext.toc" , "t1.toc" , "t2.toc" , "t3.toc" , "t4.toc" , "t5.toc" , "t6.toc" , "t7.toc" , "t8.toc" , "t9.toc" , "t10.toc" , "data1.toc" , "data2.toc" , "data5.toc" , "data6.toc" , "data7.toc" , "vcd2.toc" ] badToc :: [FilePath] badToc = [ "bad-cat1.toc" , "bad-cat2.toc" , "bad-cat3.toc" , "bad-file.toc" , "bad-mode1.toc" , "bad-msf-1.toc" , "bad-msf-2.toc" , "bad-msf-3.toc" ] open :: U.Test open = "TOC files open the associated device correctly" ~: U.TestCase $ do c <- cdioOpen (Just $ dataFile "cdtext.toc") DriverUnknown cdio <- case c of Nothing -> U.assertFailure "Can't open the TOC file" Just c' -> return c' checkMmc cdio $ Just False checkAccessMode cdio [Image] checkSource cdio [dataFile "cdtext.toc"]