Skip to content

Commit a442377

Browse files
committed
[test] storage property for Slab
1 parent e3f0225 commit a442377

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

test/stdlib/Span/SlabSpan.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//===--- SlabSpan.swift ---------------------------------------------------===//
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(-enable-experimental-feature LifetimeDependence -enable-experimental-feature Span -enable-experimental-feature AddressableTypes -enable-experimental-feature ValueGenerics)
14+
15+
// REQUIRES: executable_test
16+
17+
import StdlibUnittest
18+
19+
var suite = TestSuite("SlabStorageProperty")
20+
defer { runAllTests() }
21+
22+
suite.test("Slab.storage property")
23+
.skip(.custom(
24+
{ if #available(SwiftStdlib 6.1, *) { false } else { true } },
25+
reason: "Requires Swift 6.1's standard library"
26+
))
27+
.code {
28+
guard #available(SwiftStdlib 6.1, *) else { return }
29+
30+
var s = Slab<5, Int>(repeating: 0)
31+
s[3] = .random(in: 0..<1000)
32+
let storage = s.storage
33+
expectEqual(storage.count, s.count)
34+
for i in 0..<s.count {
35+
expectEqual(storage[i], s[i])
36+
}
37+
}

0 commit comments

Comments
 (0)