fix: align slice/set equality and harden queue API
This commit is contained in:
@@ -56,6 +56,18 @@ func TestSlice_Equal(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSlice_EqualIgnoresCapacity(t *testing.T) {
|
||||
a1 := make(Slice[int], 2, 2)
|
||||
a2 := make(Slice[int], 2, 4)
|
||||
|
||||
a1[0], a1[1] = 1, 2
|
||||
a2[0], a2[1] = 1, 2
|
||||
|
||||
if !a1.Equal(a2) {
|
||||
t.Errorf("a1 != a2")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSlice_Pop(t *testing.T) {
|
||||
a1 := make(Slice[int], 10)
|
||||
a2 := make(Slice[int], 9)
|
||||
@@ -76,3 +88,17 @@ func TestSlice_Pop(t *testing.T) {
|
||||
t.Errorf("a1 != a2")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSlice_PopFrontEqual(t *testing.T) {
|
||||
a1 := make(Slice[int], 3, 5)
|
||||
a2 := make(Slice[int], 2, 2)
|
||||
|
||||
a1[0], a1[1], a1[2] = 0, 1, 2
|
||||
a2[0], a2[1] = 1, 2
|
||||
|
||||
a1 = a1.Pop(0)
|
||||
|
||||
if !a1.Equal(a2) {
|
||||
t.Errorf("a1 != a2")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user