@@ -1755,6 +1755,55 @@ VIDEOS=StopgapVideos
1755
1755
}
1756
1756
#endif
1757
1757
}
1758
+
1759
+ func test_windowsPaths( ) throws {
1760
+ let fm = FileManager . default
1761
+ let tmpPath = writableTestDirectoryURL. path
1762
+ do {
1763
+ try fm. createDirectory ( atPath: tmpPath, withIntermediateDirectories: true , attributes: nil )
1764
+ } catch {
1765
+ XCTFail ( )
1766
+ }
1767
+ fm. changeCurrentDirectoryPath ( tmpPath)
1768
+ func checkPath( path: String ) throws {
1769
+ XCTAssertTrue ( fm. createFile ( atPath: path, contents: Data ( ) , attributes: nil ) )
1770
+ XCTAssertTrue ( fm. fileExists ( atPath: path) )
1771
+ try fm. removeItem ( atPath: path)
1772
+ XCTAssertFalse ( fm. fileExists ( atPath: path) )
1773
+
1774
+ let url = URL ( fileURLWithPath: path)
1775
+ try " hello world " . write ( to: url, atomically: false , encoding: . utf8)
1776
+ try fm. removeItem ( atPath: path)
1777
+ XCTAssertFalse ( fm. fileExists ( atPath: path) )
1778
+ }
1779
+ let paths = [
1780
+ // Absolute Paths
1781
+ " \( tmpPath) \\ testfile " , // C:/Users/...\testfile
1782
+ " \( tmpPath) /testfile " , // C:/Users.../testfile
1783
+ " \( tmpPath) /testfile " , // /Users/user/.../testfile
1784
+ " \( tmpPath. first!) :testfile " , // C:testfile
1785
+
1786
+ // Relative Paths
1787
+ " . \\ testfile " ,
1788
+ " .. \\ \( tmpPath. lastPathComponent) \\ . \\ testfile " ,
1789
+ " testfile " ,
1790
+ " ./testfile " ,
1791
+ " ../ \( tmpPath. lastPathComponent) /./testfile " ,
1792
+
1793
+ // UNC Paths
1794
+ " \\ \\ . \\ \( tmpPath) \\ testfile " ,
1795
+ " \\ \\ . \\ \( tmpPath) /testfile " ,
1796
+ " \\ \\ ? \\ \( String ( tmpPath. map ( { $0 == " / " ? " \\ " : $0} ) ) ) \\ testfile " ,
1797
+
1798
+ // Unicode characters which require a single WCHAR
1799
+ " λf.(λx.f(x x) λx.f(x x)) " ,
1800
+ // Unicode characters which require more than a single WCHAR
1801
+ " 👁️💖🐦 " ,
1802
+ ]
1803
+ for path in paths {
1804
+ try checkPath ( path: path)
1805
+ }
1806
+ }
1758
1807
1759
1808
// -----
1760
1809
@@ -1827,7 +1876,13 @@ VIDEOS=StopgapVideos
1827
1876
( " test_fetchXDGPathsFromHelper " , test_fetchXDGPathsFromHelper) ,
1828
1877
] )
1829
1878
#endif
1830
-
1879
+
1880
+ #if os(Windows)
1881
+ tests. append ( contentsOf: [
1882
+ ( " test_windowsPaths " , test_windowsPaths) ,
1883
+ ] )
1884
+ #endif
1885
+
1831
1886
return tests
1832
1887
}
1833
1888
}
0 commit comments