git.iko.soy/typeable/pandoc
on 2.4 help sign in
41 lines 2.1 kB history raw
1{-# LANGUAGE NoImplicitPrelude #-}
2module Tests.Shared (tests) where
4import Prelude
5import System.FilePath.Posix (joinPath)
6import Test.Tasty
7import Test.Tasty.HUnit (assertBool, testCase, (@?=))
8import Text.Pandoc.Arbitrary ()
9import Text.Pandoc.Builder
10import Text.Pandoc.Shared
12tests :: [TestTree]
13tests = [ testGroup "compactifyDL"
14 [ testCase "compactifyDL with empty def" $
15 assertBool "compactifyDL"
16 (let x = [(str "word", [para (str "def"), mempty])]
17 in compactifyDL x == x)
18 ]
19 , testGroup "collapseFilePath" testCollapse
20 ]
22testCollapse :: [TestTree]
23testCollapse = map (testCase "collapse")
24 [ collapseFilePath (joinPath [ ""]) @?= (joinPath [ ""])
25 , collapseFilePath (joinPath [ ".","foo"]) @?= (joinPath [ "foo"])
26 , collapseFilePath (joinPath [ ".",".","..","foo"]) @?= (joinPath [ joinPath ["..", "foo"]])
27 , collapseFilePath (joinPath [ "..","foo"]) @?= (joinPath [ "..","foo"])
28 , collapseFilePath (joinPath [ "","bar","..","baz"]) @?= (joinPath [ "","baz"])
29 , collapseFilePath (joinPath [ "","..","baz"]) @?= (joinPath [ "","..","baz"])
30 , collapseFilePath (joinPath [ ".","foo","..",".","bar","..",".",".","baz"]) @?= (joinPath [ "baz"])
31 , collapseFilePath (joinPath [ ".",""]) @?= (joinPath [ ""])
32 , collapseFilePath (joinPath [ ".",".",""]) @?= (joinPath [ ""])
33 , collapseFilePath (joinPath [ "..",""]) @?= (joinPath [ ".."])
34 , collapseFilePath (joinPath [ "..",".",""]) @?= (joinPath [ ".."])
35 , collapseFilePath (joinPath [ ".","..",""]) @?= (joinPath [ ".."])
36 , collapseFilePath (joinPath [ "..","..",""]) @?= (joinPath [ "..",".."])
37 , collapseFilePath (joinPath [ "parent","foo","baz","..","bar"]) @?= (joinPath [ "parent","foo","bar"])
38 , collapseFilePath (joinPath [ "parent","foo","baz","..","..","bar"]) @?= (joinPath [ "parent","bar"])
39 , collapseFilePath (joinPath [ "parent","foo",".."]) @?= (joinPath [ "parent"])
40 , collapseFilePath (joinPath [ "","parent","foo","..","..","bar"]) @?= (joinPath [ "","bar"])
41 , collapseFilePath (joinPath [ "",".","parent","foo"]) @?= (joinPath [ "","parent","foo"])]