aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2014-08-08 21:03:41 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2014-08-08 22:31:02 +0100
commit5b5e53024dd9dcaae11f871404baceedc63a4f29 (patch)
treed057211bd237eae60c645c653b30d7654456c464
parent2d956677eff4ce5635e37f389f1d2efd6f34615c (diff)
downloadpandoc-5b5e53024dd9dcaae11f871404baceedc63a4f29.tar.gz
Added tests for collapseFilePath
-rw-r--r--tests/Tests/Shared.hs24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/Tests/Shared.hs b/tests/Tests/Shared.hs
index c9e2e21f5..b6671835c 100644
--- a/tests/Tests/Shared.hs
+++ b/tests/Tests/Shared.hs
@@ -6,7 +6,7 @@ import Test.Framework
import Tests.Helpers
import Tests.Arbitrary()
import Test.Framework.Providers.HUnit
-import Test.HUnit ( assertBool )
+import Test.HUnit ( assertBool, (@?=) )
import Text.Pandoc.Builder
import Data.Monoid
@@ -23,6 +23,7 @@ tests = [ testGroup "normalize"
(let x = [(str "word", [para (str "def"), mempty])]
in compactify'DL x == x)
]
+ , testGroup "collapseFilePath" testCollapse
]
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 ils = null ils' || last 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")]