From 4ea19dd03e4c9632ee09a94f32f18a12df02da9e Mon Sep 17 00:00:00 2001 From: Brian Chang Date: Wed, 13 Aug 2025 13:47:48 +0800 Subject: [PATCH] [SortedSet] Add test case for indexOf --- .../SortedSet/SortedSet Tests.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Tests/SortedCollectionsTests/SortedSet/SortedSet Tests.swift b/Tests/SortedCollectionsTests/SortedSet/SortedSet Tests.swift index 67d08419..5e2a2705 100644 --- a/Tests/SortedCollectionsTests/SortedSet/SortedSet Tests.swift +++ b/Tests/SortedCollectionsTests/SortedSet/SortedSet Tests.swift @@ -80,6 +80,20 @@ class SortedSetTests: CollectionTestCase { } } + func test_indexOf() { + withEvery("count", in: 0 ..< 40) { count in + let set = SortedSet(0 ..< count) + withEvery("item", in: 0 ..< count) { item in + expectNotNil(set.index(of: item)) { index in + expectEqual(set[index], item) + let offset = set.distance(from: set.startIndex, to: index) + expectEqual(offset, item) + } + } + expectNil(set.index(of: count)) + } + } + func test_removeAtIndex() { withEvery("count", in: 0 ..< 40) { count in withEvery("index", in: 0..