2011-01-29 19:03:00 +01:00
|
|
|
module Tests.Shared (tests) where
|
|
|
|
|
|
|
|
import Text.Pandoc.Shared
|
|
|
|
import Test.Framework
|
2016-10-14 14:45:36 +02:00
|
|
|
import Text.Pandoc.Arbitrary()
|
2014-07-25 19:53:04 +02:00
|
|
|
import Test.Framework.Providers.HUnit
|
2014-08-08 22:03:41 +02:00
|
|
|
import Test.HUnit ( assertBool, (@?=) )
|
2014-07-25 19:53:04 +02:00
|
|
|
import Text.Pandoc.Builder
|
2015-09-27 07:40:58 +02:00
|
|
|
import System.FilePath.Posix (joinPath)
|
2011-01-29 19:03:00 +01:00
|
|
|
|
|
|
|
tests :: [Test]
|
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
|
|
|
]
|
|
|
|
|
2014-08-08 22:03:41 +02:00
|
|
|
testCollapse :: [Test]
|
|
|
|
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"]))]
|