1 -- | Minimal XML functionality needed to parse each document's
9 import Data.Maybe ( listToMaybe, mapMaybe )
10 import Test.Tasty ( TestTree, testGroup )
11 import Test.Tasty.HUnit ( (@?=), Assertion, testCase )
12 import Text.Read ( readMaybe )
13 import Text.XML.HXT.Core (
22 -- | A tiny parser written in HXT to extract the "XML_File_ID" element
24 parse_xmlfid :: String -> Maybe Integer
26 listToMaybe . mapMaybe readMaybe . parse
28 parse :: String -> [String]
32 /> hasName "XML_File_ID"
46 xml_file_id_tests :: TestTree
48 testCase "XML_File_ID is parsed correctly" $ do
49 let xmlfids = ["19908216", "19908216", "19908245", "19908246", "19908247"]
52 check :: String -> Assertion
54 xml <- readFile ("test/xml/" ++ xmlfid ++ ".xml")
55 let actual = parse_xmlfid xml
56 let expected = readMaybe xmlfid