summaryrefslogtreecommitdiff
path: root/tests/Tests/Helpers.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2011-01-13 10:59:44 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2011-01-13 10:59:44 -0800
commit4ccd30fe3ec899389e8159cc51e830c9edd9f875 (patch)
treee90110f5065afad4f832ee9f4fe1079d33b21aa8 /tests/Tests/Helpers.hs
parent99c361d2b433a90525e3dea002cd8700e6596a09 (diff)
Moved Tests.Shared -> Tests.Helpers.
Tests.Shared would be the natural place to put tests for functions in Text.Pandoc.Shared.
Diffstat (limited to 'tests/Tests/Helpers.hs')
-rw-r--r--tests/Tests/Helpers.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/Tests/Helpers.hs b/tests/Tests/Helpers.hs
new file mode 100644
index 000000000..272fa16bc
--- /dev/null
+++ b/tests/Tests/Helpers.hs
@@ -0,0 +1,26 @@
+module Tests.Helpers 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 = readerTestWithState defaultParserState readLaTeX
+
+readerTestWithState :: ParserState -> (ParserState -> String -> Pandoc) -> String -> String -> Expect -> Test
+readerTestWithState state reader name string exp = testCase name $ exp `assertPandoc` reader state string
+