This is an automated email from the ASF dual-hosted git repository.

hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new cf384eb09 chore(tests): replace to slices.Reverse() in go test (#3352)
cf384eb09 is described below

commit cf384eb09dae69ab0b857964ca1a7c8e30094e41
Author: Byeonggyu Park <[email protected]>
AuthorDate: Wed Jan 28 12:09:09 2026 +0900

    chore(tests): replace to slices.Reverse() in go test (#3352)
    
    Remove `util.ReverseSlice()` and replace to `slices.Reverse()`
    - From Go 1.21, `slices.Reverse()` included in standard library
    - Refer to https://pkg.go.dev/slices#Reverse
---
 tests/gocase/unit/type/stream/stream_test.go |  3 ++-
 tests/gocase/unit/type/zset/zset_test.go     |  4 ++--
 tests/gocase/util/slices.go                  | 26 --------------------------
 3 files changed, 4 insertions(+), 29 deletions(-)

diff --git a/tests/gocase/unit/type/stream/stream_test.go 
b/tests/gocase/unit/type/stream/stream_test.go
index 4593d3c27..4245c59ae 100644
--- a/tests/gocase/unit/type/stream/stream_test.go
+++ b/tests/gocase/unit/type/stream/stream_test.go
@@ -24,6 +24,7 @@ import (
        "context"
        "fmt"
        "math/rand"
+       "slices"
        "strconv"
        "strings"
        "testing"
@@ -313,7 +314,7 @@ var streamTests = func(t *testing.T, configs 
util.KvrocksServerConfigs) {
        t.Run("XREVRANGE returns the reverse of XRANGE", func(t *testing.T) {
                items := rdb.XRange(ctx, "mystream", "-", "+").Val()
                revItems := rdb.XRevRange(ctx, "mystream", "+", "-").Val()
-               util.ReverseSlice(revItems)
+               slices.Reverse(revItems)
                require.EqualValues(t, items, revItems)
        })
 
diff --git a/tests/gocase/unit/type/zset/zset_test.go 
b/tests/gocase/unit/type/zset/zset_test.go
index 6f5effde9..aea45de83 100644
--- a/tests/gocase/unit/type/zset/zset_test.go
+++ b/tests/gocase/unit/type/zset/zset_test.go
@@ -893,7 +893,7 @@ func basicTests(t *testing.T, rdb *redis.Client, ctx 
context.Context, enabledRES
                createZset(rdb, ctx, "mzset", zsetInt)
                require.Equal(t, zsetInt, rdb.ZRangeByScoreWithScores(ctx, 
"mzset", &redis.ZRangeBy{Min: "-inf", Max: "+inf"}).Val())
                require.Equal(t, zsetInt, rdb.ZRangeArgsWithScores(ctx, 
redis.ZRangeArgs{Key: "mzset", Start: "-inf", Stop: "+inf", ByScore: 
true}).Val())
-               util.ReverseSlice(zsetInt)
+               slices.Reverse(zsetInt)
                require.Equal(t, zsetInt, rdb.ZRevRangeByScoreWithScores(ctx, 
"mzset", &redis.ZRangeBy{Min: "-inf", Max: "+inf"}).Val())
                require.Equal(t, zsetInt, rdb.ZRangeArgsWithScores(ctx, 
redis.ZRangeArgs{Key: "mzset", Start: "-inf", Stop: "+inf", ByScore: true, Rev: 
true}).Val())
 
@@ -907,7 +907,7 @@ func basicTests(t *testing.T, rdb *redis.Client, ctx 
context.Context, enabledRES
                createZset(rdb, ctx, "mzset", zsetDouble)
                require.Equal(t, zsetDouble, rdb.ZRangeByScoreWithScores(ctx, 
"mzset", &redis.ZRangeBy{Min: "-inf", Max: "+inf"}).Val())
                require.Equal(t, zsetDouble, rdb.ZRangeArgsWithScores(ctx, 
redis.ZRangeArgs{Key: "mzset", Start: "-inf", Stop: "+inf", ByScore: 
true}).Val())
-               util.ReverseSlice(zsetDouble)
+               slices.Reverse(zsetDouble)
                require.Equal(t, zsetDouble, 
rdb.ZRevRangeByScoreWithScores(ctx, "mzset", &redis.ZRangeBy{Min: "-inf", Max: 
"+inf"}).Val())
                require.Equal(t, zsetDouble, rdb.ZRangeArgsWithScores(ctx, 
redis.ZRangeArgs{Key: "mzset", Start: "-inf", Stop: "+inf", ByScore: true, Rev: 
true}).Val())
        })
diff --git a/tests/gocase/util/slices.go b/tests/gocase/util/slices.go
deleted file mode 100644
index 91abdcaff..000000000
--- a/tests/gocase/util/slices.go
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package util
-
-func ReverseSlice[T any](s []T) {
-       for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
-               s[i], s[j] = s[j], s[i]
-       }
-}

Reply via email to