diff --git a/Tests/SpanTests/MutableSpanSlicing.swift b/Tests/SpanTests/MutableSpanSlicing.swift new file mode 100644 index 00000000..60cfe4bd --- /dev/null +++ b/Tests/SpanTests/MutableSpanSlicing.swift @@ -0,0 +1,144 @@ +//===--- MutableSpanSlicing.swift -----------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +import XCTest +import Span + +//MARK: slicing tests and examples +@available(macOS 9999, *) +extension MutableSpanTests { + + private func modify(_ s: inout MutableSpan) { + s[0] += 100 + } + + public func testSliceAsExtractingFunction() { + let count = 8 + let b = UnsafeMutableBufferPointer.allocate(capacity: count) + _ = b.initialize(fromContentsOf: 0...allocate(capacity: count) + _ = b.initialize(fromContentsOf: 0..) { + s[s.offset] += 100 + } + + public func testSliceAsWrapperType() { + let count = 8 + let b = UnsafeMutableBufferPointer.allocate(capacity: count) + _ = b.initialize(fromContentsOf: 0...allocate(capacity: count) + _ = b.initialize(fromContentsOf: 0..) { - s[0] += 100 - } - - public func testSliceAsExtractingFunction() { - let count = 8 - let b = UnsafeMutableBufferPointer.allocate(capacity: count) - _ = b.initialize(fromContentsOf: 0...allocate(capacity: count) - _ = b.initialize(fromContentsOf: 0..) { - s[s.offset] += 100 - } - - public func testSliceAsWrapperType() { - let count = 8 - let b = UnsafeMutableBufferPointer.allocate(capacity: count) - _ = b.initialize(fromContentsOf: 0...allocate(capacity: count) - _ = b.initialize(fromContentsOf: 0..