]> gitweb.michael.orlitzky.com - dead/htsn.git/blobdiff - src/TSN/Xml.hs
Add a Tasty test suite.
[dead/htsn.git] / src / TSN / Xml.hs
index ead8015de509481f31ca9ec3b4e23ac89b0fadc5..ddde728afa9c76727a427c849ee14a0d4a140100 100644 (file)
@@ -3,11 +3,14 @@
 --
 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 (
   (>>>),
   (/>),
@@ -35,3 +38,25 @@ parse_xmlfid =
 -- | 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