diff options
author | mpickering <matthewtpickering@gmail.com> | 2014-09-25 12:42:53 +0100 |
---|---|---|
committer | mpickering <matthewtpickering@gmail.com> | 2014-09-25 12:42:53 +0100 |
commit | cc07d0c6bfac7081118d3cbf0baea197593adc11 (patch) | |
tree | 500298023a5249a5ab09a628e7508495e8bef521 /tests | |
parent | 56e4ecab20613d86a6660547ed87e7ff4b80d632 (diff) | |
download | pandoc-cc07d0c6bfac7081118d3cbf0baea197593adc11.tar.gz |
Shared: Make collapseFilePath OS-agnostic
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Tests/Shared.hs | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/tests/Tests/Shared.hs b/tests/Tests/Shared.hs index b6671835c..9b55b7b1d 100644 --- a/tests/Tests/Shared.hs +++ b/tests/Tests/Shared.hs @@ -9,6 +9,7 @@ import Test.Framework.Providers.HUnit import Test.HUnit ( assertBool, (@?=) ) import Text.Pandoc.Builder import Data.Monoid +import System.FilePath (joinPath) tests :: [Test] tests = [ testGroup "normalize" @@ -40,21 +41,21 @@ p_normalize_no_trailing_spaces ils = null ils' || last 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")] + [ (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"]))] |