Skip to content

Commit

Permalink
Merge pull request #287 from lorentey/fix-BitSet-isEqualSet
Browse files Browse the repository at this point in the history
[BitSet] Fix a thinko in BitSet.isEqualSet
  • Loading branch information
lorentey committed May 19, 2023
2 parents 7de462e + de0f594 commit 523a409
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/BitCollections/BitSet/BitSet._UnsafeHandle.swift
Expand Up @@ -223,8 +223,8 @@ extension _UnsafeBitSet {
let r = range.clamped(to: 0 ..< UInt(capacity))
guard r == range else { return false }

let lower = Index(range.lowerBound)
let upper = Index(range.upperBound)
let lower = Index(range.lowerBound).split
let upper = Index(range.upperBound).endSplit

guard upper.word == wordCount &- 1 else { return false }

Expand Down
8 changes: 8 additions & 0 deletions Tests/BitCollectionsTests/BitSetTests.swift
Expand Up @@ -1109,6 +1109,14 @@ final class BitSetTest: CollectionTestCase {

let c = BitSet(130 ..< 160)
expectTrue(c.isEqualSet(to: 130 ..< 160))

withEvery("i", in: stride(from: 0, to: 200, by: 4)) { i in
withEvery("j", in: stride(from: i, to: 200, by: 4)) { j in
let c = BitSet(i ..< j)
expectTrue(c.isEqualSet(to: i ..< j))
expectFalse(c.isEqualSet(to: i ..< (j + 1)))
}
}
}

func test_isEqual_to_counted_BitSet() {
Expand Down

0 comments on commit 523a409

Please sign in to comment.