mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-09 10:40:26 +08:00
bug fix: bit map for each bit
This commit is contained in:
@@ -74,10 +74,13 @@ func (b *BitMap) ForEachBit(begin int64, end int64, cb Callback) {
|
|||||||
}
|
}
|
||||||
bitOffset++
|
bitOffset++
|
||||||
offset++
|
offset++
|
||||||
|
if offset >= end {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
byteIndex++
|
byteIndex++
|
||||||
bitOffset = 0
|
bitOffset = 0
|
||||||
if end > 0 && offset == end {
|
if end > 0 && offset >= end {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -67,7 +67,7 @@ func TestForEachBit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
expectOffset := int64(100)
|
expectOffset := int64(100)
|
||||||
count := 0
|
count := 0
|
||||||
bm.ForEachBit(100, 200, func(offset int64, val byte) bool {
|
bm.ForEachBit(100, 201, func(offset int64, val byte) bool {
|
||||||
if offset != expectOffset {
|
if offset != expectOffset {
|
||||||
t.Error("wrong offset")
|
t.Error("wrong offset")
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ func TestForEachBit(t *testing.T) {
|
|||||||
count++
|
count++
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
if count != 100 {
|
if count != 101 {
|
||||||
t.Error("wrong count")
|
t.Error("wrong count")
|
||||||
}
|
}
|
||||||
bm = New()
|
bm = New()
|
||||||
|
Reference in New Issue
Block a user