tpathnorm.nim 1011 B

12345678910111213141516171819202122232425262728293031323334353637
  1. discard """
  2. matrix: "--mm:refc; --mm:orc"
  3. """
  4. import std/os
  5. import std/assertions
  6. when doslikeFileSystem:
  7. import std/pathnorm
  8. template initVars =
  9. var state {.inject.} = 0
  10. var result {.inject.}: string
  11. block: # / -> /
  12. initVars
  13. addNormalizePath("//?/c:/./foo//bar/../baz", result, state, '/')
  14. doAssert result == "//?/c:/foo/baz"
  15. addNormalizePath("me", result, state, '/')
  16. doAssert result == "//?/c:/foo/baz/me"
  17. block: # / -> \
  18. initVars
  19. addNormalizePath(r"//?/c:/./foo//bar/../baz", result, state, '\\')
  20. doAssert result == r"\\?\c:\foo\baz"
  21. addNormalizePath("me", result, state, '\\')
  22. doAssert result == r"\\?\c:\foo\baz\me"
  23. block: # Append path component to UNC drive
  24. initVars
  25. addNormalizePath(r"//?/c:", result, state, '\\')
  26. doAssert result == r"\\?\c:"
  27. addNormalizePath("Users", result, state, '\\')
  28. doAssert result == r"\\?\c:\Users"
  29. addNormalizePath("me", result, state, '\\')
  30. doAssert result == r"\\?\c:\Users\me"