Skip to content

Commit 523a409

Browse files
authored
Merge pull request #287 from lorentey/fix-BitSet-isEqualSet
[BitSet] Fix a thinko in BitSet.isEqualSet
2 parents 7de462e + de0f594 commit 523a409

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Sources/BitCollections/BitSet/BitSet._UnsafeHandle.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ extension _UnsafeBitSet {
223223
let r = range.clamped(to: 0 ..< UInt(capacity))
224224
guard r == range else { return false }
225225

226-
let lower = Index(range.lowerBound)
227-
let upper = Index(range.upperBound)
226+
let lower = Index(range.lowerBound).split
227+
let upper = Index(range.upperBound).endSplit
228228

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

Tests/BitCollectionsTests/BitSetTests.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,14 @@ final class BitSetTest: CollectionTestCase {
11091109

11101110
let c = BitSet(130 ..< 160)
11111111
expectTrue(c.isEqualSet(to: 130 ..< 160))
1112+
1113+
withEvery("i", in: stride(from: 0, to: 200, by: 4)) { i in
1114+
withEvery("j", in: stride(from: i, to: 200, by: 4)) { j in
1115+
let c = BitSet(i ..< j)
1116+
expectTrue(c.isEqualSet(to: i ..< j))
1117+
expectFalse(c.isEqualSet(to: i ..< (j + 1)))
1118+
}
1119+
}
11121120
}
11131121

11141122
func test_isEqual_to_counted_BitSet() {

0 commit comments

Comments
 (0)