]> gitweb.michael.orlitzky.com - dead/htsn.git/blobdiff - src/TSN/Xml.hs
Based on TSN documentation, split XML documents on the </message> tag instead of...
[dead/htsn.git] / src / TSN / Xml.hs
index 1f057f9982cd9b299a1c97db2913ecc395e12118..4c1123f0c71f5aa4b20794031b262a862363ccc7 100644 (file)
@@ -1,10 +1,15 @@
+-- | Minimal XML functionality needed to parse each document's
+--   XML_File_ID.
+--
 module TSN.Xml (
   parse_xmlfid,
-  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 (
   (>>>),
   (/>),
@@ -29,6 +34,24 @@ parse_xmlfid =
                >>> getText)
 
 
--- | 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