+-- | Minimal XML functionality needed to parse each document's
+-- XML_File_ID.
+--
module TSN.Xml (
parse_xmlfid,
- xml_prologue )
+ xml_prologue,
+ xml_tests )
where
-import Data.Maybe (listToMaybe, mapMaybe)
-import Text.Read (readMaybe)
+import Data.Maybe ( listToMaybe, mapMaybe )
+import Test.Tasty ( TestTree, testGroup )
+import Test.Tasty.HUnit ( (@?=), Assertion, testCase )
+import Text.Read ( readMaybe )
import Text.XML.HXT.Core (
(>>>),
(/>),
-- | The opening "tag" for the XML prologue.
xml_prologue :: String
xml_prologue = "<?xml "
+
+
+-- * Tasty Tests
+xml_tests :: TestTree
+xml_tests =
+ testGroup
+ "XML tests"
+ [ xml_file_id_tests ]
+
+
+xml_file_id_tests :: TestTree
+xml_file_id_tests =
+ testCase "XML_File_ID is parsed correctly" $ do
+ let xmlfids = ["19908216", "19908216", "19908245", "19908246", "19908247"]
+ mapM_ check xmlfids
+ where
+ check :: String -> Assertion
+ check xmlfid = do
+ xml <- readFile ("test/xml/" ++ xmlfid ++ ".xml")
+ let actual = parse_xmlfid xml
+ let expected = readMaybe xmlfid
+ actual @?= expected