Skip to content

Commit

Permalink
Improve test coverage for PreviousSet and PreviousClear
Browse files Browse the repository at this point in the history
The missing coverage was probing multiple words and failing to find anything.
  • Loading branch information
lukesandberg committed Nov 15, 2024
1 parent cbd10cc commit 40adb31
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions bitset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,23 @@ func TestPreviousSet(t *testing.T) {
}
})
}
v.ClearAll()
for _, tt := range []struct {
index uint
want uint
wantFound bool
}{
{0, 0, false},
{120, 0, false},
{1024, 0, false},
} {
t.Run(fmt.Sprintf("@%d", tt.index), func(t *testing.T) {
got, found := v.PreviousSet(tt.index)
if got != tt.want || found != tt.wantFound {
t.Errorf("PreviousSet(%d) = %d, %v, want %d, %v", tt.index, got, found, tt.want, tt.wantFound)
}
})
}
}

func TestPreviousClear(t *testing.T) {
Expand Down Expand Up @@ -2148,4 +2165,21 @@ func TestPreviousClear(t *testing.T) {
}
})
}
v.SetAll()
for _, tt := range []struct {
index uint
want uint
wantFound bool
}{
{0, 0, false},
{120, 0, false},
{1024, 0, false},
} {
t.Run(fmt.Sprintf("@%d", tt.index), func(t *testing.T) {
got, found := v.PreviousClear(tt.index)
if got != tt.want || found != tt.wantFound {
t.Errorf("PreviousClear(%d) = %d, %v, want %d, %v", tt.index, got, found, tt.want, tt.wantFound)
}
})
}
}

0 comments on commit 40adb31

Please sign in to comment.