Skip to content

Commit 40adb31

Browse files
committed
Improve test coverage for PreviousSet and PreviousClear
The missing coverage was probing multiple words and failing to find anything.
1 parent cbd10cc commit 40adb31

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

bitset_test.go

+34
Original file line numberDiff line numberDiff line change
@@ -2117,6 +2117,23 @@ func TestPreviousSet(t *testing.T) {
21172117
}
21182118
})
21192119
}
2120+
v.ClearAll()
2121+
for _, tt := range []struct {
2122+
index uint
2123+
want uint
2124+
wantFound bool
2125+
}{
2126+
{0, 0, false},
2127+
{120, 0, false},
2128+
{1024, 0, false},
2129+
} {
2130+
t.Run(fmt.Sprintf("@%d", tt.index), func(t *testing.T) {
2131+
got, found := v.PreviousSet(tt.index)
2132+
if got != tt.want || found != tt.wantFound {
2133+
t.Errorf("PreviousSet(%d) = %d, %v, want %d, %v", tt.index, got, found, tt.want, tt.wantFound)
2134+
}
2135+
})
2136+
}
21202137
}
21212138

21222139
func TestPreviousClear(t *testing.T) {
@@ -2148,4 +2165,21 @@ func TestPreviousClear(t *testing.T) {
21482165
}
21492166
})
21502167
}
2168+
v.SetAll()
2169+
for _, tt := range []struct {
2170+
index uint
2171+
want uint
2172+
wantFound bool
2173+
}{
2174+
{0, 0, false},
2175+
{120, 0, false},
2176+
{1024, 0, false},
2177+
} {
2178+
t.Run(fmt.Sprintf("@%d", tt.index), func(t *testing.T) {
2179+
got, found := v.PreviousClear(tt.index)
2180+
if got != tt.want || found != tt.wantFound {
2181+
t.Errorf("PreviousClear(%d) = %d, %v, want %d, %v", tt.index, got, found, tt.want, tt.wantFound)
2182+
}
2183+
})
2184+
}
21512185
}

0 commit comments

Comments
 (0)