From f2aea0f8e6eff0e0a6bbc352ecd945acea911786 Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Mon, 24 Feb 2025 09:11:13 -0800 Subject: [PATCH] separate slicing tests --- Tests/SpanTests/MutableSpanSlicing.swift | 144 +++++++++++++++++++++++ Tests/SpanTests/MutableSpanTests.swift | 130 -------------------- 2 files changed, 144 insertions(+), 130 deletions(-) create mode 100644 Tests/SpanTests/MutableSpanSlicing.swift 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..