Skip to content

Commit

Permalink
[test] storage property for Slab
Browse files Browse the repository at this point in the history
  • Loading branch information
glessard committed Jan 10, 2025
1 parent e3f0225 commit a442377
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/stdlib/Span/SlabSpan.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//===--- SlabSpan.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
//
//===----------------------------------------------------------------------===//

// RUN: %target-run-stdlib-swift(-enable-experimental-feature LifetimeDependence -enable-experimental-feature Span -enable-experimental-feature AddressableTypes -enable-experimental-feature ValueGenerics)

// REQUIRES: executable_test

import StdlibUnittest

var suite = TestSuite("SlabStorageProperty")
defer { runAllTests() }

suite.test("Slab.storage property")
.skip(.custom(
{ if #available(SwiftStdlib 6.1, *) { false } else { true } },
reason: "Requires Swift 6.1's standard library"
))
.code {
guard #available(SwiftStdlib 6.1, *) else { return }

var s = Slab<5, Int>(repeating: 0)
s[3] = .random(in: 0..<1000)
let storage = s.storage
expectEqual(storage.count, s.count)
for i in 0..<s.count {
expectEqual(storage[i], s[i])
}
}

0 comments on commit a442377

Please sign in to comment.