aboutsummaryrefslogtreecommitdiff
path: root/tests/Tests/Shared.hs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Tests/Shared.hs')
-rw-r--r--tests/Tests/Shared.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/Tests/Shared.hs b/tests/Tests/Shared.hs
new file mode 100644
index 000000000..3cf8d5689
--- /dev/null
+++ b/tests/Tests/Shared.hs
@@ -0,0 +1,26 @@
+module Tests.Shared where
+
+import Text.Pandoc
+
+import Test.Framework
+import Test.Framework.Providers.HUnit
+import Test.HUnit hiding (Test)
+
+data Expect = Inline Inline
+ | Inlines [Inline]
+ | Block Block
+ | Blocks [Block]
+
+assertPandoc :: Expect -> Pandoc -> Assertion
+assertPandoc (Inline e) (Pandoc _ [Para [g]]) = e @=? g
+assertPandoc (Inlines e) (Pandoc _ [Para g] ) = e @=? g
+assertPandoc (Block e) (Pandoc _ [g] ) = e @=? g
+assertPandoc (Blocks e) (Pandoc _ g ) = e @=? g
+assertPandoc _ _ = assertFailure "Wrong structure of Pandoc document."
+
+latexTest :: String-> String -> Expect -> Test
+latexTest = latexTestWithState defaultParserState
+
+latexTestWithState :: ParserState -> String -> String -> Expect -> Test
+latexTestWithState state name string exp = testCase name $ exp `assertPandoc` readLaTeX state string
+