diff options
author | Federico Ceratto <federico.ceratto@gmail.com> | 2017-10-24 20:30:48 +0100 |
---|---|---|
committer | Federico Ceratto <federico.ceratto@gmail.com> | 2018-07-06 20:21:39 +0100 |
commit | d65429d857f927b6110217611feb94b18ee7f2a4 (patch) | |
tree | 585b7a375e5c482c868d4d66cde55a99aded5f8a /tests/stdlib/tos.nim | |
parent | 352b8a4844a4211fb7381f2f0d0b9e40dcb3cc72 (diff) | |
download | Nim-d65429d857f927b6110217611feb94b18ee7f2a4.tar.gz |
Add normalizePath and tests
Diffstat (limited to 'tests/stdlib/tos.nim')
-rw-r--r-- | tests/stdlib/tos.nim | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/stdlib/tos.nim b/tests/stdlib/tos.nim index c7643b701..6ccc29bf6 100644 --- a/tests/stdlib/tos.nim +++ b/tests/stdlib/tos.nim @@ -43,6 +43,7 @@ true true true true + ''' """ # test os path creation, iteration, and deletion @@ -137,8 +138,69 @@ import times let tm = fromUnix(0) + 100.microseconds writeFile("a", "") setLastModificationTime("a", tm) + when defined(macosx): echo "true" else: echo getLastModificationTime("a") == tm removeFile("a") + +when defined(Linux) or defined(osx): + + block normalizedPath: + 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" + +else: + + block normalizedPath: + 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" |