From e1ab86805936103d3820f1f44097655dbf048b70 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 13 Jul 2023 10:00:45 -0700 Subject: [PATCH] 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. --- .../SystemTests/FilePathTests/FilePathTest.swift | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/Tests/SystemTests/FilePathTests/FilePathTest.swift b/Tests/SystemTests/FilePathTests/FilePathTest.swift index b008b15b..1686faa1 100644 --- a/Tests/SystemTests/FilePathTests/FilePathTest.swift +++ b/Tests/SystemTests/FilePathTests/FilePathTest.swift @@ -16,20 +16,7 @@ import System #endif @available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *) -func filePathFromInvalidCodePointSequence(_ bytes: S) -> FilePath where S.Element == UTF16.CodeUnit { - var array = Array(bytes) - assert(array.last != 0, "already null terminated") - array += [0] - - return array.withUnsafeBufferPointer { - $0.withMemoryRebound(to: CInterop.PlatformChar.self) { - FilePath(platformString: $0.baseAddress!) - } - } -} - -@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *) -func filePathFromInvalidCodePointSequence(_ bytes: S) -> FilePath where S.Element == UTF8.CodeUnit { +func filePathFromInvalidCodePointSequence(_ bytes: S) -> FilePath where S.Element == CInterop.PlatformUnicodeEncoding.CodeUnit { var array = Array(bytes) assert(array.last != 0, "already null terminated") array += [0]