Skip to content

Commit e1ab868

Browse files
committed
Tests: avoid unnecessary duplication (NFCI)
Rather than specialising the function with the same implementation, prefer to use the `CInterop.PlatformUnicodeEncoding` to determine the correct code point encoding. This allows us to share the implementation across the platforms.
1 parent 022a7fe commit e1ab868

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

Tests/SystemTests/FilePathTests/FilePathTest.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,7 @@ import System
1616
#endif
1717

1818
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
19-
func filePathFromInvalidCodePointSequence<S: Sequence>(_ bytes: S) -> FilePath where S.Element == UTF16.CodeUnit {
20-
var array = Array(bytes)
21-
assert(array.last != 0, "already null terminated")
22-
array += [0]
23-
24-
return array.withUnsafeBufferPointer {
25-
$0.withMemoryRebound(to: CInterop.PlatformChar.self) {
26-
FilePath(platformString: $0.baseAddress!)
27-
}
28-
}
29-
}
30-
31-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
32-
func filePathFromInvalidCodePointSequence<S: Sequence>(_ bytes: S) -> FilePath where S.Element == UTF8.CodeUnit {
19+
func filePathFromInvalidCodePointSequence<S: Sequence>(_ bytes: S) -> FilePath where S.Element == CInterop.PlatformUnicodeEncoding.CodeUnit {
3320
var array = Array(bytes)
3421
assert(array.last != 0, "already null terminated")
3522
array += [0]

0 commit comments

Comments
 (0)