File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ //===--- SpanBytesProperty.swift --- test Span's bytes property -----------===//
2
+ //
3
+ // This source file is part of the Swift.org open source project
4
+ //
5
+ // Copyright (c) 2025 Apple Inc. and the Swift project authors
6
+ // Licensed under Apache License v2.0 with Runtime Library Exception
7
+ //
8
+ // See https://swift.org/LICENSE.txt for license information
9
+ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
+ //
11
+ //===----------------------------------------------------------------------===//
12
+
13
+ // RUN: %target-run-stdlib-swift
14
+
15
+ // REQUIRES: executable_test
16
+
17
+ import Swift
18
+ import StdlibUnittest
19
+
20
+ var suite = TestSuite ( " SpanBytesProperty " )
21
+ defer { runAllTests ( ) }
22
+
23
+ suite. test ( " Span/bytes property " )
24
+ . skip ( . custom(
25
+ { if #available( SwiftStdlib 6 . 2 , * ) { false } else { true } } ,
26
+ reason: " Requires Swift 6.2's standard library "
27
+ ) )
28
+ . code {
29
+ guard #available( SwiftStdlib 6 . 2 , * ) else { return }
30
+
31
+ let capacity = 4
32
+ let a = ContiguousArray ( 0 ..< capacity)
33
+ a. withUnsafeBufferPointer {
34
+ let bytes = $0. span. bytes
35
+
36
+ expectEqual ( bytes. byteCount, capacity*MemoryLayout< Int> . stride)
37
+ expectEqual ( bytes. unsafeLoad ( fromByteOffset: 3 , as: UInt8 . self) , 0 )
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments