Skip to content

Commit 074c32b

Browse files
Merge pull request #124 from brentp/isempty
fix bitarray/IsEmpty()
2 parents 0f802a9 + 75c27ff commit 074c32b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

bitarray/bitarray.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func (ba *bitArray) Blocks() Iterator {
233233
}
234234

235235
func (ba *bitArray) IsEmpty() bool {
236-
return ba.anyset
236+
return !ba.anyset
237237
}
238238

239239
// complement flips all bits in this array.

bitarray/bitarray_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ func TestOutOfBounds(t *testing.T) {
134134
}
135135
}
136136

137+
func TestIsEmpty(t *testing.T) {
138+
ba := newBitArray(10)
139+
assert.True(t, ba.IsEmpty())
140+
141+
ba.SetBit(5)
142+
assert.False(t, ba.IsEmpty())
143+
}
144+
137145
func TestClear(t *testing.T) {
138146
ba := newBitArray(10)
139147

0 commit comments

Comments
 (0)