os.nim: use the new pathnorm.normalizePath implementation
This commit is contained in:
parent
5b39c7aca9
commit
ce9815bcf5
4 changed files with 67 additions and 85 deletions
|
|
@ -190,61 +190,32 @@ block walkDirRec:
|
|||
removeDir("walkdir_test")
|
||||
|
||||
block normalizedPath:
|
||||
when defined(posix):
|
||||
block relative:
|
||||
doAssert normalizedPath(".") == "."
|
||||
doAssert normalizedPath("..") == ".."
|
||||
doAssert normalizedPath("../") == ".."
|
||||
doAssert normalizedPath("../..") == "../.."
|
||||
doAssert normalizedPath("../a/..") == ".."
|
||||
doAssert normalizedPath("../a/../") == ".."
|
||||
doAssert normalizedPath("./") == "."
|
||||
block relative:
|
||||
doAssert normalizedPath(".") == ""
|
||||
doAssert normalizedPath("..") == ".."
|
||||
doAssert normalizedPath("../") == ".."
|
||||
doAssert normalizedPath("../..") == unixToNativePath"../.."
|
||||
doAssert normalizedPath("../a/..") == ".."
|
||||
doAssert normalizedPath("../a/../") == ".."
|
||||
doAssert normalizedPath("./") == ""
|
||||
|
||||
block absolute:
|
||||
doAssert normalizedPath("/") == "/"
|
||||
doAssert normalizedPath("/.") == "/"
|
||||
doAssert normalizedPath("/..") == "/"
|
||||
doAssert normalizedPath("/../") == "/"
|
||||
doAssert normalizedPath("/../..") == "/"
|
||||
doAssert normalizedPath("/../../") == "/"
|
||||
doAssert normalizedPath("/../../../") == "/"
|
||||
doAssert normalizedPath("/a/b/../../foo") == "/foo"
|
||||
doAssert normalizedPath("/a/b/../../../foo") == "/foo"
|
||||
doAssert normalizedPath("/./") == "/"
|
||||
doAssert normalizedPath("//") == "/"
|
||||
doAssert normalizedPath("///") == "/"
|
||||
doAssert normalizedPath("/a//b") == "/a/b"
|
||||
doAssert normalizedPath("/a///b") == "/a/b"
|
||||
doAssert normalizedPath("/a/b/c/..") == "/a/b"
|
||||
doAssert normalizedPath("/a/b/c/../") == "/a/b"
|
||||
|
||||
else:
|
||||
block relative:
|
||||
doAssert normalizedPath(".") == "."
|
||||
doAssert normalizedPath("..") == ".."
|
||||
doAssert normalizedPath("..\\") == ".."
|
||||
doAssert normalizedPath("..\\..") == "..\\.."
|
||||
doAssert normalizedPath("..\\a\\..") == ".."
|
||||
doAssert normalizedPath("..\\a\\..\\") == ".."
|
||||
doAssert normalizedPath(".\\") == "."
|
||||
|
||||
block absolute:
|
||||
doAssert normalizedPath("\\") == "\\"
|
||||
doAssert normalizedPath("\\.") == "\\"
|
||||
doAssert normalizedPath("\\..") == "\\"
|
||||
doAssert normalizedPath("\\..\\") == "\\"
|
||||
doAssert normalizedPath("\\..\\..") == "\\"
|
||||
doAssert normalizedPath("\\..\\..\\") == "\\"
|
||||
doAssert normalizedPath("\\..\\..\\..\\") == "\\"
|
||||
doAssert normalizedPath("\\a\\b\\..\\..\\foo") == "\\foo"
|
||||
doAssert normalizedPath("\\a\\b\\..\\..\\..\\foo") == "\\foo"
|
||||
doAssert normalizedPath("\\.\\") == "\\"
|
||||
doAssert normalizedPath("\\\\") == "\\"
|
||||
doAssert normalizedPath("\\\\\\") == "\\"
|
||||
doAssert normalizedPath("\\a\\\\b") == "\\a\\b"
|
||||
doAssert normalizedPath("\\a\\\\\\b") == "\\a\\b"
|
||||
doAssert normalizedPath("\\a\\b\\c\\..") == "\\a\\b"
|
||||
doAssert normalizedPath("\\a\\b\\c\\..\\") == "\\a\\b"
|
||||
block absolute:
|
||||
doAssert normalizedPath("/") == unixToNativePath"/"
|
||||
doAssert normalizedPath("/.") == unixToNativePath"/"
|
||||
doAssert normalizedPath("/..") == unixToNativePath"/.."
|
||||
doAssert normalizedPath("/../") == unixToNativePath"/.."
|
||||
doAssert normalizedPath("/../..") == unixToNativePath"/../.."
|
||||
doAssert normalizedPath("/../../") == unixToNativePath"/../.."
|
||||
doAssert normalizedPath("/../../../") == unixToNativePath"/../../.."
|
||||
doAssert normalizedPath("/a/b/../../foo") == unixToNativePath"/foo"
|
||||
doAssert normalizedPath("/a/b/../../../foo") == unixToNativePath"/../foo"
|
||||
doAssert normalizedPath("/./") == unixToNativePath"/"
|
||||
doAssert normalizedPath("//") == unixToNativePath"/"
|
||||
doAssert normalizedPath("///") == unixToNativePath"/"
|
||||
doAssert normalizedPath("/a//b") == unixToNativePath"/a/b"
|
||||
doAssert normalizedPath("/a///b") == unixToNativePath"/a/b"
|
||||
doAssert normalizedPath("/a/b/c/..") == unixToNativePath"/a/b"
|
||||
doAssert normalizedPath("/a/b/c/../") == unixToNativePath"/a/b"
|
||||
|
||||
block isHidden:
|
||||
when defined(posix):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue