-
Notifications
You must be signed in to change notification settings - Fork 357
Closed
Milestone
Description
I am adopting CollectionsTestSupport code for my own testing purpose. I noticed that in checkCollection, distance(from:to:), the testing code seems to get all possible pairs of all indices, rather than making sure that the first index is less or equal to the second one:
swift-collections/Sources/CollectionsTestSupport/ConformanceCheckers/CheckCollection.swift
Lines 204 to 210 in f1c6cb4
| // Check `distance(from:to:)` | |
| withEvery("i", in: allIndices.indices) { i in | |
| withEvery("j", in: allIndices.indices) { j in | |
| let d = collection.distance(from: allIndices[i], to: allIndices[j]) | |
| expectEqual(d, j - i) | |
| } | |
| } |
I believe the documentation for Collection says:
Unless the collection conforms to the BidirectionalCollection protocol, start must be less than or equal to end.
So this is probably a bug? It causes issues for my non-bidirectional collections.
Metadata
Metadata
Assignees
Labels
No labels