Fix TestReverseSlice for go 1.21
Go 1.21 does a better job using the same empty allocation for empty slices, check for cap > 0 before requiring slices to have different backing arrays. Bug: 309895579 Test: TestReverseSlice Change-Id: Ic48e9cf2c95ea0b810a11cdc4a794a70c02a0a61
This commit is contained in:
@@ -811,7 +811,7 @@ func TestReverseSlice(t *testing.T) {
|
||||
if !reflect.DeepEqual(slice, testCase.expected) {
|
||||
t.Errorf("expected %#v, got %#v", testCase.expected, slice)
|
||||
}
|
||||
if slice != nil && unsafe.SliceData(testCase.in) == unsafe.SliceData(slice) {
|
||||
if cap(slice) > 0 && unsafe.SliceData(testCase.in) == unsafe.SliceData(slice) {
|
||||
t.Errorf("expected slices to have different backing arrays")
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user