diff --git a/bitset.go b/bitset.go index d0fbff9..5751b68 100644 --- a/bitset.go +++ b/bitset.go @@ -953,7 +953,7 @@ func (b *BitSet) ReadFrom(stream io.Reader) (int64, error) { } var item [8]byte - nWords := wordsNeeded(uint(length))//b.wordCount() + nWords := wordsNeeded(uint(length)) reader := bufio.NewReader(io.LimitReader(stream, 8*int64(nWords))) for i := 0; i < nWords; i++ { if _, err := io.ReadFull(reader, item[:]); err != nil { diff --git a/bitset_test.go b/bitset_test.go index efa202f..601c274 100644 --- a/bitset_test.go +++ b/bitset_test.go @@ -1395,6 +1395,16 @@ func TestSetBitsetFrom(t *testing.T) { } } +func TestIssue116(t *testing.T) { + a := []uint64{2, 3, 5, 7, 11} + b := []uint64{2, 3, 5, 7, 11, 0, 1} + bitset1 := FromWithLength(320, a) + bitset2 := FromWithLength(320, b) + if !bitset1.Equal(bitset2) || !bitset2.Equal(bitset1) { + t.Error("Bitsets should be equal irrespective of the underlying capacity") + } +} + func TestFrom(t *testing.T) { u := []uint64{2, 3, 5, 7, 11} b := From(u)