Added tests for collapseFilePath
This commit is contained in:
parent
2d956677ef
commit
5b5e53024d
1 changed files with 23 additions and 1 deletions
|
@ -6,7 +6,7 @@ import Test.Framework
|
||||||
import Tests.Helpers
|
import Tests.Helpers
|
||||||
import Tests.Arbitrary()
|
import Tests.Arbitrary()
|
||||||
import Test.Framework.Providers.HUnit
|
import Test.Framework.Providers.HUnit
|
||||||
import Test.HUnit ( assertBool )
|
import Test.HUnit ( assertBool, (@?=) )
|
||||||
import Text.Pandoc.Builder
|
import Text.Pandoc.Builder
|
||||||
import Data.Monoid
|
import Data.Monoid
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ tests = [ testGroup "normalize"
|
||||||
(let x = [(str "word", [para (str "def"), mempty])]
|
(let x = [(str "word", [para (str "def"), mempty])]
|
||||||
in compactify'DL x == x)
|
in compactify'DL x == x)
|
||||||
]
|
]
|
||||||
|
, testGroup "collapseFilePath" testCollapse
|
||||||
]
|
]
|
||||||
|
|
||||||
p_normalize_blocks_rt :: [Block] -> Bool
|
p_normalize_blocks_rt :: [Block] -> Bool
|
||||||
|
@ -36,3 +37,24 @@ p_normalize_inlines_rt ils =
|
||||||
p_normalize_no_trailing_spaces :: [Inline] -> Bool
|
p_normalize_no_trailing_spaces :: [Inline] -> Bool
|
||||||
p_normalize_no_trailing_spaces ils = null ils' || last ils' /= Space
|
p_normalize_no_trailing_spaces ils = null ils' || last ils' /= Space
|
||||||
where ils' = normalizeInlines $ ils ++ [Space]
|
where ils' = normalizeInlines $ ils ++ [Space]
|
||||||
|
|
||||||
|
testCollapse :: [Test]
|
||||||
|
testCollapse = map (testCase "collapse")
|
||||||
|
[ (collapseFilePath "" @?= "")
|
||||||
|
, (collapseFilePath "./foo" @?= "foo")
|
||||||
|
, (collapseFilePath "././../foo" @?= "../foo")
|
||||||
|
, (collapseFilePath "../foo" @?= "../foo")
|
||||||
|
, (collapseFilePath "/bar/../baz" @?= "/baz")
|
||||||
|
, (collapseFilePath "/../baz" @?= "/../baz")
|
||||||
|
, (collapseFilePath "./foo/.././bar/../././baz" @?= "baz")
|
||||||
|
, (collapseFilePath "./" @?= "")
|
||||||
|
, (collapseFilePath "././" @?= "")
|
||||||
|
, (collapseFilePath "../" @?= "..")
|
||||||
|
, (collapseFilePath ".././" @?= "..")
|
||||||
|
, (collapseFilePath "./../" @?= "..")
|
||||||
|
, (collapseFilePath "../../" @?= "../..")
|
||||||
|
, (collapseFilePath "parent/foo/baz/../bar" @?= "parent/foo/bar")
|
||||||
|
, (collapseFilePath "parent/foo/baz/../../bar" @?= "parent/bar")
|
||||||
|
, (collapseFilePath "parent/foo/.." @?= "parent")
|
||||||
|
, (collapseFilePath "/parent/foo/../../bar" @?= "/bar")
|
||||||
|
, (collapseFilePath "/./parent/foo" @?= "/parent/foo")]
|
||||||
|
|
Loading…
Reference in a new issue