Skip to content

Bug in CheckCollection from CollectionsTestSupport? #59

@notcome

Description

@notcome

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:

// 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions