diff options
Diffstat (limited to 'test/Tests/Shared.hs')
-rw-r--r-- | test/Tests/Shared.hs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/Tests/Shared.hs b/test/Tests/Shared.hs new file mode 100644 index 000000000..9b9aeb6a3 --- /dev/null +++ b/test/Tests/Shared.hs @@ -0,0 +1,40 @@ +module Tests.Shared (tests) where + +import Text.Pandoc.Shared +import Test.Framework +import Text.Pandoc.Arbitrary() +import Test.Framework.Providers.HUnit +import Test.HUnit ( assertBool, (@?=) ) +import Text.Pandoc.Builder +import System.FilePath.Posix (joinPath) + +tests :: [Test] +tests = [ testGroup "compactifyDL" + [ testCase "compactifyDL with empty def" $ + assertBool "compactifyDL" + (let x = [(str "word", [para (str "def"), mempty])] + in compactifyDL x == x) + ] + , testGroup "collapseFilePath" testCollapse + ] + +testCollapse :: [Test] +testCollapse = map (testCase "collapse") + [ (collapseFilePath (joinPath [ ""]) @?= (joinPath [ ""])) + , (collapseFilePath (joinPath [ ".","foo"]) @?= (joinPath [ "foo"])) + , (collapseFilePath (joinPath [ ".",".","..","foo"]) @?= (joinPath [ joinPath ["..", "foo"]])) + , (collapseFilePath (joinPath [ "..","foo"]) @?= (joinPath [ "..","foo"])) + , (collapseFilePath (joinPath [ "","bar","..","baz"]) @?= (joinPath [ "","baz"])) + , (collapseFilePath (joinPath [ "","..","baz"]) @?= (joinPath [ "","..","baz"])) + , (collapseFilePath (joinPath [ ".","foo","..",".","bar","..",".",".","baz"]) @?= (joinPath [ "baz"])) + , (collapseFilePath (joinPath [ ".",""]) @?= (joinPath [ ""])) + , (collapseFilePath (joinPath [ ".",".",""]) @?= (joinPath [ ""])) + , (collapseFilePath (joinPath [ "..",""]) @?= (joinPath [ ".."])) + , (collapseFilePath (joinPath [ "..",".",""]) @?= (joinPath [ ".."])) + , (collapseFilePath (joinPath [ ".","..",""]) @?= (joinPath [ ".."])) + , (collapseFilePath (joinPath [ "..","..",""]) @?= (joinPath [ "..",".."])) + , (collapseFilePath (joinPath [ "parent","foo","baz","..","bar"]) @?= (joinPath [ "parent","foo","bar"])) + , (collapseFilePath (joinPath [ "parent","foo","baz","..","..","bar"]) @?= (joinPath [ "parent","bar"])) + , (collapseFilePath (joinPath [ "parent","foo",".."]) @?= (joinPath [ "parent"])) + , (collapseFilePath (joinPath [ "","parent","foo","..","..","bar"]) @?= (joinPath [ "","bar"])) + , (collapseFilePath (joinPath [ "",".","parent","foo"]) @?= (joinPath [ "","parent","foo"]))] |