File tree 2 files changed +28
-0
lines changed
Sources/Testing/Attachments
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -104,13 +104,27 @@ extension UnsafeBufferPointer<UInt8>: Test.Attachable {
104
104
}
105
105
}
106
106
107
+ @_spi ( Experimental)
108
+ extension UnsafeMutableBufferPointer < UInt8 > : Test . Attachable {
109
+ public func withUnsafeBufferPointer< R> ( for attachment: borrowing Test . Attachment , _ body: ( UnsafeRawBufferPointer ) throws -> R ) throws -> R {
110
+ try body ( . init( self ) )
111
+ }
112
+ }
113
+
107
114
@_spi ( Experimental)
108
115
extension UnsafeRawBufferPointer : Test . Attachable {
109
116
public func withUnsafeBufferPointer< R> ( for attachment: borrowing Test . Attachment , _ body: ( UnsafeRawBufferPointer ) throws -> R ) throws -> R {
110
117
try body ( self )
111
118
}
112
119
}
113
120
121
+ @_spi ( Experimental)
122
+ extension UnsafeMutableRawBufferPointer : Test . Attachable {
123
+ public func withUnsafeBufferPointer< R> ( for attachment: borrowing Test . Attachment , _ body: ( UnsafeRawBufferPointer ) throws -> R ) throws -> R {
124
+ try body ( . init( self ) )
125
+ }
126
+ }
127
+
114
128
@_spi ( Experimental)
115
129
extension String : Test . Attachable {
116
130
public func withUnsafeBufferPointer< R> ( for attachment: borrowing Test . Attachment , _ body: ( UnsafeRawBufferPointer ) throws -> R ) throws -> R {
Original file line number Diff line number Diff line change @@ -201,13 +201,27 @@ extension AttachmentTests {
201
201
}
202
202
}
203
203
204
+ @Test func uint8UnsafeMutableBufferPointer( ) throws {
205
+ var value : [ UInt8 ] = Array ( " abc123 " . utf8)
206
+ try value. withUnsafeMutableBufferPointer { value in
207
+ try test ( value)
208
+ }
209
+ }
210
+
204
211
@Test func unsafeRawBufferPointer( ) throws {
205
212
let value : [ UInt8 ] = Array ( " abc123 " . utf8)
206
213
try value. withUnsafeBytes { value in
207
214
try test ( value)
208
215
}
209
216
}
210
217
218
+ @Test func unsafeMutableRawBufferPointer( ) throws {
219
+ var value : [ UInt8 ] = Array ( " abc123 " . utf8)
220
+ try value. withUnsafeMutableBytes { value in
221
+ try test ( value)
222
+ }
223
+ }
224
+
211
225
@Test func string( ) throws {
212
226
let value = " abc123 "
213
227
try test ( value)
You can’t perform that action at this time.
0 commit comments