@@ -281,110 +281,6 @@ suite.test("storeBytes(of:as:)")
281281 expectEqual ( a [ 0 ] . bigEndian & 0xffff , 0xffff )
282282}
283283
284- suite. test ( " update(from: some Sequence<some BitwiseCopyable>) " )
285- . skip ( . custom(
286- { if #available( SwiftStdlib 6 . 2 , * ) { false } else { true } } ,
287- reason: " Requires Swift 6.2's standard library "
288- ) )
289- . code {
290- guard #available( SwiftStdlib 6 . 2 , * ) else { return }
291-
292- let capacity = 8
293- var a = Array ( repeating: Int . max, count: capacity)
294- expectEqual ( a. allSatisfy ( { $0 == . max } ) , true )
295- a. withUnsafeMutableBufferPointer {
296- let empty = UnsafeMutableBufferPointer < Int > ( start: nil , count: 0 )
297- var span = MutableRawSpan ( _unsafeElements: empty)
298- var ( iterator, updated) = span. update ( from: 0 ..< 0 )
299- expectNil ( iterator. next ( ) )
300- expectEqual ( updated, 0 )
301-
302- span = MutableRawSpan ( _unsafeElements: $0)
303- ( iterator, updated) = span. update ( from: 0 ..< 0 )
304- expectNil ( iterator. next ( ) )
305- expectEqual ( updated, 0 )
306-
307- ( iterator, updated) = span. update ( from: 0 ..< 10000 )
308- expectNotNil ( iterator. next ( ) )
309- expectEqual ( updated, capacity*MemoryLayout< Int> . stride)
310- }
311- expectEqual ( a. elementsEqual ( 0 ..< capacity) , true )
312- }
313-
314- suite. test ( " update(from: some Collection<some BitwiseCopyable>) " )
315- . skip ( . custom(
316- { if #available( SwiftStdlib 6 . 2 , * ) { false } else { true } } ,
317- reason: " Requires Swift 6.2's standard library "
318- ) )
319- . code {
320- guard #available( SwiftStdlib 6 . 2 , * ) else { return }
321-
322- let capacity = 8
323- var a = Array ( repeating: Int . max, count: capacity)
324- let e = Array ( EmptyCollection < UInt > ( ) )
325- expectEqual ( a. allSatisfy ( { $0 == . max } ) , true )
326- a. withUnsafeMutableBytes {
327- let emptyPrefix = $0. prefix ( 0 )
328- var span = MutableRawSpan ( _unsafeBytes: emptyPrefix)
329- var updated = span. update ( fromContentsOf: e)
330- expectEqual ( updated, 0 )
331-
332-
333- updated = span. update ( fromContentsOf: AnyCollection ( e) )
334- expectEqual ( updated, 0 )
335-
336- span = MutableRawSpan ( _unsafeBytes: $0)
337- updated = span. update ( fromContentsOf: 0 ..< capacity)
338- expectEqual ( updated, capacity*MemoryLayout< Int> . stride)
339- }
340- expectEqual ( a. elementsEqual ( 0 ..< capacity) , true )
341- }
342-
343- suite. test ( " update(fromContentsOf:) (contiguous memory) " )
344- . skip ( . custom(
345- { if #available( SwiftStdlib 6 . 2 , * ) { false } else { true } } ,
346- reason: " Requires Swift 6.2's standard library "
347- ) )
348- . code {
349- guard #available( SwiftStdlib 6 . 2 , * ) else { return }
350-
351- let capacity = 8
352- var a = Array ( repeating: Int . max, count: capacity)
353- expectEqual ( a. allSatisfy ( { $0 == . max } ) , true )
354- a. withUnsafeMutableBytes {
355- var span = MutableRawSpan ( _unsafeBytes: $0)
356- let array = Array ( 0 ..< capacity)
357- var updated = span. update ( fromContentsOf: array. prefix ( 0 ) )
358- expectEqual ( updated, 0 )
359-
360- updated = span. update ( fromContentsOf: array)
361- expectEqual ( updated, capacity*MemoryLayout< Int> . stride)
362- }
363- expectEqual ( a. elementsEqual ( 0 ..< capacity) , true )
364-
365- a. withUnsafeMutableBytes {
366- var span = MutableRawSpan ( _unsafeBytes: $0)
367- var array = Array ( repeating: Int . min, count: capacity)
368- array. withUnsafeMutableBytes {
369- let source = MutableRawSpan ( _unsafeBytes: $0)
370- let updated = span. update ( fromContentsOf: source)
371- expectEqual ( updated, capacity*MemoryLayout< Int> . stride)
372- }
373- }
374- expectEqual ( a. allSatisfy ( { $0 == Int . min } ) , true )
375-
376- a. withUnsafeMutableBytes {
377- var span = MutableRawSpan ( _unsafeBytes: $0)
378- let array = Array ( 0 ..< capacity)
379- array. withUnsafeBufferPointer {
380- let source = Span ( _unsafeElements: $0)
381- let updated = span. update ( fromContentsOf: source)
382- expectEqual ( updated, capacity*MemoryLayout< Int> . stride)
383- }
384- }
385- expectEqual ( a. elementsEqual ( 0 ..< capacity) , true )
386- }
387-
388284suite. test ( " _mutatingExtracting() " )
389285. skip ( . custom(
390286 { if #available( SwiftStdlib 6 . 2 , * ) { false } else { true } } ,
0 commit comments