Check SortedSet.SubSequence's Equatable and Hashable conformances

SortedSet.SubSequence has its own copy of SortedSet's == and
hash(into:), and neither was tested. Equal slices are taken from
bulk-built and inserted sets, so they start at different leaf offsets;
the last two classes match the evens slice in count and endpoints and
differ only past the first leaf.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Joseph CursioandClaude Opus 5.5 committed 2026-09-26 23:13:08 -05:00
1 parent fac3148fe7
commit e4c7f6e3d8
1 file changed
+16
@@ -278,6 +278,22 @@ class SortedSetTests: CollectionTestCase {
checkHashable(equivalenceClasses: classes)
}
func test_subSequence_Equatable_Hashable() {
let evens = stride(from: 0, to: 80, by: 2)
let classes: [[SortedSet<Int>.SubSequence]] = [
[SortedSet<Int>()[0 ..< 10], SortedSet(0 ..< 40)[50 ..< 60]],
[
SortedSet(sortedElements: 0 ..< 40)[10 ..< 30],
SortedSet(0 ..< 40)[10 ..< 30],
SortedSet(10 ..< 30)[...],
],
[SortedSet(evens)[20 ..< 60]],
[SortedSet(evens.map { $0 == 40 ? 41 : $0 })[20 ..< 60]],
[SortedSet(evens.map { $0 == 56 ? 57 : $0 })[20 ..< 60]],
]
checkHashable(equivalenceClasses: classes)
}
func test_Encodable() throws {
let s1: SortedSet<Int> = []
let v1: MinimalEncoder.Value = .array([])