diff --git a/src/Test.hs b/src/Test.hs
index 28c627b..4a72c64 100644
--- a/src/Test.hs
+++ b/src/Test.hs
@@ -3,29 +3,41 @@ module MdToHtmlTest where
import MdToHTML
import Test.HUnit
-check_equal expected actual
+check_equal :: String -> String -> String -> Test
+check_equal desc expected actual = TestCase (assertEqual desc expected actual)
+
+convert :: String -> String
+convert md = show . fst $ leftmostLongestParse parseDocument md
headerTests = TestList
[
- (TestCase (assertEqual "Should convert H1 heading" "
Hello
" (show . fst $ leftmostLongestParse parseLine "# Hello"))),
- (TestCase (assertEqual "Should convert H2 heading" "Hello
" (show . fst $ leftmostLongestParse parseLine "## Hello"))),
- (TestCase (assertEqual "Should convert H3 heading" "Hello
" (show . fst $ leftmostLongestParse parseLine "### Hello"))),
- (TestCase (assertEqual "Should convert H4 heading" "Hello
" (show . fst $ leftmostLongestParse parseLine "#### Hello"))),
- (TestCase (assertEqual "Should convert H5 heading" "Hello
" (show . fst $ leftmostLongestParse parseLine "##### Hello"))),
- (TestCase (assertEqual "Should convert H6 heading" "Hello
" (show . fst $ leftmostLongestParse parseLine "###### Hello")))
+ check_equal "Should convert H1 heading" "Hello
" (convert "# Hello"),
+ check_equal "Should convert H2 heading" "Hello
" (convert "## Hello"),
+ check_equal "Should convert H3 heading" "Hello
" (convert "### Hello"),
+ check_equal "Should convert H4 heading" "Hello
" (convert "#### Hello"),
+ check_equal "Should convert H5 heading" "Hello
" (convert "##### Hello"),
+ check_equal "Should convert H6 heading" "Hello
" (convert "###### Hello")
]
boldTests = TestList
[
- (TestCase (assertEqual "Should convert bold" "Hello" (show . fst $ leftmostLongestParse parseLine "__Hello__"))),
- (TestCase (assertEqual "Should convert italic" "Hello" (show . fst $ leftmostLongestParse parseLine "_Hello_"))),
- (TestCase (assertEqual "Should convert bold and italic in a sentence" "It is a wonderful day" (show . fst $ leftmostLongestParse parseLine "It _is_ a __wonderful__ day")))
- ]
+ check_equal "Should convert bold" "Hello
" (convert "__Hello__"),
+ check_equal "Should convert italic" "Hello
" (convert "_Hello_"),
+ check_equal "Should convert bold and italic in a sentence" "It is a wonderful day
" (convert "It _is_ a __wonderful__ day")
+ ]
+
+integrationTests = TestList
+ [
+ check_equal "Integration 1" "Sample Markdown
This is some basic, sample markdown.
Second Heading
" (convert "# Sample Markdown\n\n This is some basic, sample markdown.\n\n ## __Second__ _Heading_")
+ -- Add a test for single-newlines.
+ ]
+
tests = TestList
[
headerTests,
- boldTests
+ boldTests,
+ integrationTests
]
runTests = runTestTT tests