summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2023-11-08 22:08:29 -0800
committer Colin Cross <ccross@android.com> 2023-11-08 22:11:24 -0800
commitf2fab8347d88216afa60826ea7741435d680acbb (patch)
tree549149c6cc0b9d094270afcbf5084306abf86b97
parent216ed6c9181d56f65ee8750ad0f3723f511737fe (diff)
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
-rw-r--r--android/util_test.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/android/util_test.go b/android/util_test.go
index 20161e52d..699135bfc 100644
--- a/android/util_test.go
+++ b/android/util_test.go
@@ -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")
}
})