2011-01-29 19:03:00 +01:00
|
|
|
module Tests.Shared (tests) where
|
|
|
|
|
2017-03-04 13:03:41 +01:00
|
|
|
import System.FilePath.Posix (joinPath)
|
2017-03-14 17:05:36 +01:00
|
|
|
import Test.Tasty
|
2017-10-28 05:28:29 +02:00
|
|
|
import Test.Tasty.HUnit (assertBool, testCase, (@?=))
|
2017-03-04 13:03:41 +01:00
|
|
|
import Text.Pandoc.Arbitrary ()
|
2014-07-25 19:53:04 +02:00
|
|
|
import Text.Pandoc.Builder
|
2017-03-04 13:03:41 +01:00
|
|
|
import Text.Pandoc.Shared
|
2011-01-29 19:03:00 +01:00
|
|
|
|
2017-03-14 17:05:36 +01:00
|
|
|
tests :: [TestTree]
|
2017-01-27 21:36:45 +01:00
|
|
|
tests = [ testGroup "compactifyDL"
|
|
|
|
[ testCase "compactifyDL with empty def" $
|
|
|
|
assertBool "compactifyDL"
|
2014-07-25 19:53:04 +02:00
|
|
|
(let x = [(str "word", [para (str "def"), mempty])]
|
2017-01-27 21:36:45 +01:00
|
|
|
in compactifyDL x == x)
|
2014-07-25 19:53:04 +02:00
|
|
|
]
|
2014-08-08 22:03:41 +02:00
|
|
|
, testGroup "collapseFilePath" testCollapse
|
2011-01-29 19:03:00 +01:00
|
|
|
]
|
|
|
|
|
2017-03-14 17:05:36 +01:00
|
|
|
testCollapse :: [TestTree]
|
2014-08-08 22:03:41 +02:00
|
|
|
testCollapse = map (testCase "collapse")
|
2014-09-25 13:42:53 +02:00
|
|
|
[ (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"]))]
|