File tree Expand file tree Collapse file tree 4 files changed +16
-5
lines changed Expand file tree Collapse file tree 4 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -29,10 +29,13 @@ suite.test("Basic Initializer")
2929
3030 var s = Array ( " \( #file) + \( #function) -- \( Int . random ( in: 1000 ... 9999 ) ) " . utf8)
3131 s. withUnsafeMutableBytes {
32- let b = MutableRawSpan ( _unsafeBytes: $0)
32+ var b = MutableRawSpan ( _unsafeBytes: $0)
3333 expectEqual ( b. byteCount, $0. count)
3434 expectFalse ( b. isEmpty)
3535 expectEqual ( b. byteOffsets, 0 ..< $0. count)
36+
37+ b = MutableRawSpan ( )
38+ expectEqual ( b. byteCount, 0 )
3639 }
3740}
3841
Original file line number Diff line number Diff line change @@ -30,9 +30,11 @@ suite.test("Initialize with ordinary element")
3030 let capacity = 4
3131 var s = ( 0 ..< capacity) . map ( { " \( #file) + \( #function) -- \( $0) " } )
3232 s. withUnsafeMutableBufferPointer {
33- let b = MutableSpan ( _unsafeElements: $0)
34- let c = b. count
35- expectEqual ( c, $0. count)
33+ var b = MutableSpan ( _unsafeElements: $0)
34+ expectEqual ( b. count, $0. count)
35+
36+ b = MutableSpan ( )
37+ expectEqual ( b. count, 0 )
3638 }
3739}
3840
Original file line number Diff line number Diff line change @@ -30,9 +30,12 @@ suite.test("Initialize with Span<Int>")
3030 let capacity = 4
3131 Array ( 0 ..< capacity) . withUnsafeBufferPointer {
3232 let intSpan = Span ( _unsafeElements: $0)
33- let span = RawSpan ( _elements: intSpan)
33+ var span = RawSpan ( _elements: intSpan)
3434 expectEqual ( span. byteCount, capacity*MemoryLayout< Int> . stride)
3535 expectFalse ( span. isEmpty)
36+
37+ span = RawSpan ( )
38+ expectTrue ( span. isEmpty)
3639 }
3740
3841 let a : [ Int ] = [ ]
Original file line number Diff line number Diff line change @@ -120,6 +120,9 @@ suite.test("Initialize with ordinary element")
120120 let pointer : UnsafeMutablePointer = $0. baseAddress!
121121 span = Span ( _unsafeStart: pointer, count: $0. count)
122122 expectEqual ( span. count, capacity)
123+
124+ span = Span ( )
125+ expectEqual ( span. count, 0 )
123126 }
124127}
125128
You can’t perform that action at this time.
0 commit comments