@@ -199,58 +199,6 @@ struct AttachmentTests {
199199 }
200200 }
201201
202- @Test func attachRefCountedValue( ) throws {
203- let attachableValue = MySendableAttachableWithRefcountedSemantics ( values: ( 1 , 2 , 3 ) )
204- let attachment = Test . Attachment ( attachableValue, named: " loremipsum " )
205-
206- #expect( attachment. attachableValue is MySendableAttachableWithRefcountedSemantics )
207- #expect( attachment. attachableValue. estimatedAttachmentByteCount == attachableValue. estimatedAttachmentByteCount)
208- try attachment. attachableValue. withUnsafeBufferPointer ( for: attachment) { buffer in
209- withUnsafeBytes ( of: ( 1 , 2 , 3 ) ) { buffer2 in
210- #expect( buffer. elementsEqual ( buffer2) )
211- }
212- }
213- }
214-
215- @Test func attachSmallPODValue( ) throws {
216- let attachableValue = MySendableAttachableWithSmallPODSemantics ( values: ( 1 , 2 , 3 ) )
217- let attachment = Test . Attachment ( attachableValue, named: " loremipsum " )
218-
219- #expect( !( type ( of: attachment. attachableValue) is AnyClass ) )
220- #expect( attachment. attachableValue. estimatedAttachmentByteCount == attachableValue. estimatedAttachmentByteCount)
221- try attachment. attachableValue. withUnsafeBufferPointer ( for: attachment) { buffer in
222- withUnsafeBytes ( of: ( 1 , 2 , 3 ) ) { buffer2 in
223- #expect( buffer. elementsEqual ( buffer2) )
224- }
225- }
226- }
227-
228- @Test func attachBigPODValue( ) throws {
229- let attachableValue = MySendableAttachableWithBigPODSemantics ( values: ( 1 , 2 , 3 , 4 , 5 , 6 ) )
230- let attachment = Test . Attachment ( attachableValue, named: " loremipsum " )
231-
232- #expect( type ( of: attachment. attachableValue) is AnyClass )
233- #expect( attachment. attachableValue. estimatedAttachmentByteCount == attachableValue. estimatedAttachmentByteCount)
234- try attachment. attachableValue. withUnsafeBufferPointer ( for: attachment) { buffer in
235- withUnsafeBytes ( of: ( 1 , 2 , 3 , 4 , 5 , 6 ) ) { buffer2 in
236- #expect( buffer. elementsEqual ( buffer2) )
237- }
238- }
239- }
240-
241- @Test func attachNonPODValue( ) throws {
242- let attachableValue = MySendableAttachableWithNonPODSemantics ( values: ( 1 , 2 , 3 ) )
243- let attachment = Test . Attachment ( attachableValue, named: " loremipsum " )
244-
245- #expect( type ( of: attachment. attachableValue) is AnyClass )
246- #expect( attachment. attachableValue. estimatedAttachmentByteCount == attachableValue. estimatedAttachmentByteCount)
247- try attachment. attachableValue. withUnsafeBufferPointer ( for: attachment) { buffer in
248- withUnsafeBytes ( of: ( 1 , 2 , 3 ) ) { buffer2 in
249- #expect( buffer. elementsEqual ( buffer2) )
250- }
251- }
252- }
253-
254202 @Test func issueRecordedWhenAttachingNonSendableValueThatThrows( ) async {
255203 await confirmation ( " Attachment detected " ) { valueAttached in
256204 await confirmation ( " Issue recorded " ) { issueRecorded in
@@ -374,39 +322,13 @@ struct MySendableAttachable: Test.Attachable, Sendable {
374322 }
375323}
376324
377- final class MySendableAttachableWithRefcountedSemantics : Test . Attachable , Sendable {
378- let values : ( Int , Int , Int )
379-
380- init ( values: ( Int , Int , Int ) ) {
381- self . values = values
382- }
383-
384- func withUnsafeBufferPointer< R> ( for attachment: borrowing Testing . Test . Attachment , _ body: ( UnsafeRawBufferPointer ) throws -> R ) throws -> R {
385- try withUnsafeBytes ( of: values, body)
386- }
387- }
388-
389- struct MySendableAttachableWithSmallPODSemantics : Test . Attachable , Sendable {
390- var values : ( Int , Int , Int )
391-
392- func withUnsafeBufferPointer< R> ( for attachment: borrowing Testing . Test . Attachment , _ body: ( UnsafeRawBufferPointer ) throws -> R ) throws -> R {
393- try withUnsafeBytes ( of: values, body)
394- }
395- }
396-
397- struct MySendableAttachableWithBigPODSemantics : Test . Attachable , Sendable {
398- var values : ( Int , Int , Int , Int , Int , Int )
399-
400- func withUnsafeBufferPointer< R> ( for attachment: borrowing Testing . Test . Attachment , _ body: ( UnsafeRawBufferPointer ) throws -> R ) throws -> R {
401- try withUnsafeBytes ( of: values, body)
402- }
403- }
404-
405- struct MySendableAttachableWithNonPODSemantics : Test . Attachable , Sendable {
406- var values : ( Int , Int , Int )
407- var makeItComplicated = " it's complicated "
325+ struct MySendableAttachableWithDefaultByteCount : Test . Attachable , Sendable {
326+ var string : String
408327
409328 func withUnsafeBufferPointer< R> ( for attachment: borrowing Testing . Test . Attachment , _ body: ( UnsafeRawBufferPointer ) throws -> R ) throws -> R {
410- try withUnsafeBytes ( of: values, body)
329+ var string = string
330+ return try string. withUTF8 { buffer in
331+ try body ( . init( buffer) )
332+ }
411333 }
412334}
0 commit comments