mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 17:34:43 +00:00
* Fix os.unixToNativePath proc returns wrong result(#8179) * Add tests for unixToNativePath
42 lines
1.6 KiB
Nim
42 lines
1.6 KiB
Nim
discard """
|
|
file: "tospaths.nim"
|
|
output: ""
|
|
"""
|
|
# test the ospaths module
|
|
|
|
import os
|
|
|
|
doAssert unixToNativePath("") == ""
|
|
doAssert unixToNativePath(".") == $CurDir
|
|
doAssert unixToNativePath("..") == $ParDir
|
|
doAssert isAbsolute(unixToNativePath("/"))
|
|
doAssert isAbsolute(unixToNativePath("/", "a"))
|
|
doAssert isAbsolute(unixToNativePath("/a"))
|
|
doAssert isAbsolute(unixToNativePath("/a", "a"))
|
|
doAssert isAbsolute(unixToNativePath("/a/b"))
|
|
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"
|
|
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"
|
|
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"
|