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 5c4a116d chore(tests): use built-in min and max (#2718)
5c4a116d is described below

commit 5c4a116d2d0bb0ba88893f6f5f6cf8fb714377e2
Author: fukua95 <[email protected]>
AuthorDate: Fri Jan 10 18:46:07 2025 +0800

    chore(tests): use built-in min and max (#2718)
---
 tests/gocase/unit/type/list/list_test.go |   2 +-
 tests/gocase/util/math.go                |  38 -----------
 tests/gocase/util/math_test.go           | 105 -------------------------------
 3 files changed, 1 insertion(+), 144 deletions(-)

diff --git a/tests/gocase/unit/type/list/list_test.go 
b/tests/gocase/unit/type/list/list_test.go
index ab835b94..b2bd71f5 100644
--- a/tests/gocase/unit/type/list/list_test.go
+++ b/tests/gocase/unit/type/list/list_test.go
@@ -84,7 +84,7 @@ func testLTRIM(t *testing.T, configs 
util.KvrocksServerConfigs) {
                                lo := int64(rand.Float64() * float64(startLen))
                                hi := int64(float64(lo) + 
rand.Float64()*float64(startLen))
 
-                               myList = myList[lo:util.Min(int(hi+1), 
len(myList))]
+                               myList = myList[lo:min(int(hi+1), len(myList))]
                                require.NoError(t, rdb.LTrim(ctx, key, lo, 
hi).Err())
                                require.Equal(t, myList, rdb.LRange(ctx, key, 
0, -1).Val(), "failed trim")
 
diff --git a/tests/gocase/util/math.go b/tests/gocase/util/math.go
deleted file mode 100644
index 05123b1d..00000000
--- a/tests/gocase/util/math.go
+++ /dev/null
@@ -1,38 +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
-
-import "cmp"
-
-// Min returns the smaller of two values.
-func Min[T cmp.Ordered](a, b T) T {
-       if a < b {
-               return a
-       }
-       return b
-}
-
-// Max returns the larger of two values.
-func Max[T cmp.Ordered](a, b T) T {
-       if a > b {
-               return a
-       }
-       return b
-}
diff --git a/tests/gocase/util/math_test.go b/tests/gocase/util/math_test.go
deleted file mode 100644
index 5c5a7ce9..00000000
--- a/tests/gocase/util/math_test.go
+++ /dev/null
@@ -1,105 +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_test
-
-import (
-       "testing"
-
-       "github.com/apache/kvrocks/tests/gocase/util"
-       "github.com/stretchr/testify/assert"
-)
-
-func TestMin(t *testing.T) {
-       // Arrange
-       tests := []struct {
-               name           string
-               a              int
-               b              int
-               expectedResult int
-       }{
-               {
-                       name:           "a is smaller than b",
-                       a:              1,
-                       b:              2,
-                       expectedResult: 1,
-               },
-               {
-                       name:           "a is greater than b",
-                       a:              2,
-                       b:              1,
-                       expectedResult: 1,
-               },
-               {
-                       name:           "a is equal to b",
-                       a:              1,
-                       b:              1,
-                       expectedResult: 1,
-               },
-       }
-
-       for _, tt := range tests {
-               t.Run(tt.name, func(t *testing.T) {
-                       // Act
-                       result := util.Min(tt.a, tt.b)
-
-                       //Assert
-                       assert.Equal(t, tt.expectedResult, result)
-               })
-       }
-}
-
-func TestMax(t *testing.T) {
-       // Arrange
-       tests := []struct {
-               name           string
-               a              int
-               b              int
-               expectedResult int
-       }{
-               {
-                       name:           "a is smaller than b",
-                       a:              1,
-                       b:              2,
-                       expectedResult: 2,
-               },
-               {
-                       name:           "a is greater than b",
-                       a:              2,
-                       b:              1,
-                       expectedResult: 2,
-               },
-               {
-                       name:           "a is equal to b",
-                       a:              1,
-                       b:              1,
-                       expectedResult: 1,
-               },
-       }
-
-       for _, tt := range tests {
-               t.Run(tt.name, func(t *testing.T) {
-                       // Act
-                       result := util.Max(tt.a, tt.b)
-
-                       //Assert
-                       assert.Equal(t, tt.expectedResult, result)
-               })
-       }
-}

Reply via email to