From e4c7f6e3d85b4f40efa8e4a013fa172caaca1e8e Mon Sep 17 00:00:00 2001 From: Joseph Cursio Date: Sat, 26 Sep 2026 23:13:08 -0500 Subject: [PATCH] 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 --- .../SortedSet/SortedSet Tests.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Tests/SortedCollectionsTests/SortedSet/SortedSet Tests.swift b/Tests/SortedCollectionsTests/SortedSet/SortedSet Tests.swift index b45b8408..beea2acf 100644 --- a/Tests/SortedCollectionsTests/SortedSet/SortedSet Tests.swift +++ b/Tests/SortedCollectionsTests/SortedSet/SortedSet Tests.swift @@ -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.SubSequence]] = [ + [SortedSet()[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 = [] let v1: MinimalEncoder.Value = .array([])