summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2018-10-09 10:27:31 -0700
committerAndreas Rumpf <rumpf_a@web.de>2018-10-09 19:27:31 +0200
commita98b1a7764a02c301f028c825fe93c84b0aa9547 (patch)
tree1221f0555723917e31a98f2b57a5c6630d7bc8e5 /tests
parentb97a7dbf3d1874b7dbf6b541ac57b27f8fbcd367 (diff)
downloadNim-a98b1a7764a02c301f028c825fe93c84b0aa9547.tar.gz
fix #8341: add lastPathPart (#9116)
Diffstat (limited to 'tests')
-rw-r--r--tests/stdlib/tospaths.nim61
1 files changed, 42 insertions, 19 deletions
diff --git a/tests/stdlib/tospaths.nim b/tests/stdlib/tospaths.nim
index 0ac7729d9..9e2a5605c 100644
--- a/tests/stdlib/tospaths.nim
+++ b/tests/stdlib/tospaths.nim
@@ -18,24 +18,47 @@ doAssert isAbsolute(unixToNativePath("/a/b", "a"))
 doAssert unixToNativePath("a/b") == joinPath("a", "b")

 

 when defined(macos):

-    doAssert unixToNativePath("./") == ":"

-    doAssert unixToNativePath("./abc") == ":abc"

-    doAssert unixToNativePath("../abc") == "::abc"

-    doAssert unixToNativePath("../../abc") == ":::abc"

-    doAssert unixToNativePath("/abc", "a") == "abc"

-    doAssert unixToNativePath("/abc/def", "a") == "abc:def"

+  doAssert unixToNativePath("./") == ":"

+  doAssert unixToNativePath("./abc") == ":abc"

+  doAssert unixToNativePath("../abc") == "::abc"

+  doAssert unixToNativePath("../../abc") == ":::abc"

+  doAssert unixToNativePath("/abc", "a") == "abc"

+  doAssert unixToNativePath("/abc/def", "a") == "abc:def"

 elif doslikeFileSystem:

-    doAssert unixToNativePath("./") == ".\\"

-    doAssert unixToNativePath("./abc") == ".\\abc"

-    doAssert unixToNativePath("../abc") == "..\\abc"

-    doAssert unixToNativePath("../../abc") == "..\\..\\abc"

-    doAssert unixToNativePath("/abc", "a") == "a:\\abc"

-    doAssert unixToNativePath("/abc/def", "a") == "a:\\abc\\def"

+  doAssert unixToNativePath("./") == ".\\"

+  doAssert unixToNativePath("./abc") == ".\\abc"

+  doAssert unixToNativePath("../abc") == "..\\abc"

+  doAssert unixToNativePath("../../abc") == "..\\..\\abc"

+  doAssert unixToNativePath("/abc", "a") == "a:\\abc"

+  doAssert unixToNativePath("/abc/def", "a") == "a:\\abc\\def"

 else:

-    #Tests for unix

-    doAssert unixToNativePath("./") == "./"

-    doAssert unixToNativePath("./abc") == "./abc"

-    doAssert unixToNativePath("../abc") == "../abc"

-    doAssert unixToNativePath("../../abc") == "../../abc"

-    doAssert unixToNativePath("/abc", "a") == "/abc"

-    doAssert unixToNativePath("/abc/def", "a") == "/abc/def"

+  #Tests for unix

+  doAssert unixToNativePath("./") == "./"

+  doAssert unixToNativePath("./abc") == "./abc"

+  doAssert unixToNativePath("../abc") == "../abc"

+  doAssert unixToNativePath("../../abc") == "../../abc"

+  doAssert unixToNativePath("/abc", "a") == "/abc"

+  doAssert unixToNativePath("/abc/def", "a") == "/abc/def"

+

+block extractFilenameTest:

+  doAssert extractFilename("") == ""

+  when defined(posix):

+    doAssert extractFilename("foo/bar") == "bar"

+    doAssert extractFilename("foo/bar.txt") == "bar.txt"

+    doAssert extractFilename("foo/") == ""

+    doAssert extractFilename("/") == ""

+  when doslikeFileSystem:

+    doAssert extractFilename(r"foo\bar") == "bar"

+    doAssert extractFilename(r"foo\bar.txt") == "bar.txt"

+    doAssert extractFilename(r"foo\") == ""

+    doAssert extractFilename(r"C:\") == ""

+

+block lastPathPartTest:

+  doAssert lastPathPart("") == ""

+  when defined(posix):

+    doAssert lastPathPart("foo/bar.txt") == "bar.txt"

+    doAssert lastPathPart("foo/") == "foo"

+    doAssert lastPathPart("/") == ""

+  when doslikeFileSystem:

+    doAssert lastPathPart(r"foo\bar.txt") == "bar.txt"

+    doAssert lastPathPart(r"foo\") == "foo"