summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Tests/Shared.hs17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/Tests/Shared.hs b/test/Tests/Shared.hs
index 797d9fe75..439196145 100644
--- a/test/Tests/Shared.hs
+++ b/test/Tests/Shared.hs
@@ -15,6 +15,7 @@ module Tests.Shared (tests) where
import System.FilePath.Posix (joinPath)
import Test.Tasty
import Text.Pandoc.Arbitrary ()
+import Test.Tasty.QuickCheck (testProperty)
import Text.Pandoc.Builder
import Text.Pandoc.Shared
import Test.Tasty.HUnit
@@ -33,7 +34,21 @@ tests = [ testGroup "compactifyDL"
, testGroup "collapseFilePath" testCollapse
, testGroup "toLegacyTable" testLegacyTable
, testGroup "table of contents" testTOC
- ]
+ , testGroup "makeSections"
+ [ testProperty "makeSections is idempotent" makeSectionsIsIdempotent
+ , testCase "makeSections is idempotent for test case" $
+ let d = header 1 "H1" <> header 2 "H2" <> header 3 "H3" <>
+ header 2 "H2a" <> header 4 "H4" <> header 1 "H1a"
+ d' = makeSections False Nothing $ toList d
+ in assertBool "makeSections is idempotent for test case"
+ (makeSections False Nothing d' == d')
+ ]
+ ]
+
+makeSectionsIsIdempotent :: [Block] -> Bool
+makeSectionsIsIdempotent d =
+ let d' = makeSections False Nothing d
+ in d' == makeSections False Nothing d'
givesTOC :: String -> (Blocks, Blocks) -> TestTree
givesTOC desc (blocks, toc) = test (toTableOfContents def) desc (toList blocks, head . toList $ toc)