Skip to content

Commit

Permalink
Verifying.
Browse files Browse the repository at this point in the history
  • Loading branch information
lemire committed Jan 24, 2023
1 parent c6ff005 commit 1842228
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bitset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions bitset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1842228

Please sign in to comment.