You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kvrocks.apache.org by ti...@apache.org on 2022/09/09 15:38:30 UTC

[incubator-kvrocks] branch unstable updated: Move TCL test unit/type/sint to Go case (#840)

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

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


The following commit(s) were added to refs/heads/unstable by this push:
     new 7b0821b  Move TCL test unit/type/sint to Go case (#840)
7b0821b is described below

commit 7b0821b01e32099633934883a805ad6341e1e9df
Author: Ruixiang Tan <81...@qq.com>
AuthorDate: Fri Sep 9 23:38:25 2022 +0800

    Move TCL test unit/type/sint to Go case (#840)
---
 tests/gocase/unit/type/sint/sint_test.go | 52 ++++++++++++++++++++++++++++++++
 tests/tcl/tests/test_helper.tcl          |  1 -
 tests/tcl/tests/unit/type/sint.tcl       | 34 ---------------------
 3 files changed, 52 insertions(+), 35 deletions(-)

diff --git a/tests/gocase/unit/type/sint/sint_test.go b/tests/gocase/unit/type/sint/sint_test.go
new file mode 100644
index 0000000..ec3c4ef
--- /dev/null
+++ b/tests/gocase/unit/type/sint/sint_test.go
@@ -0,0 +1,52 @@
+/*
+ * 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 sint
+
+import (
+	"context"
+	"testing"
+
+	"github.com/apache/incubator-kvrocks/tests/gocase/util"
+	"github.com/stretchr/testify/require"
+)
+
+func TestSint(t *testing.T) {
+	srv := util.StartServer(t, map[string]string{})
+	defer srv.Close()
+	ctx := context.Background()
+	rdb := srv.NewClient()
+	defer func() { require.NoError(t, rdb.Close()) }()
+
+	t.Run("sorted-int", func(t *testing.T) {
+		require.EqualValues(t, 1, rdb.Do(ctx, "SIADD", "mysi", 1).Val())
+		require.EqualValues(t, 1, rdb.Do(ctx, "SIADD", "mysi", 2).Val())
+		require.EqualValues(t, 0, rdb.Do(ctx, "SIADD", "mysi", 2).Val())
+		require.EqualValues(t, 5, rdb.Do(ctx, "SIADD", "mysi", 3, 4, 5, 123, 245).Val())
+		require.EqualValues(t, 7, rdb.Do(ctx, "SICARD", "mysi").Val())
+		require.EqualValues(t, []interface{}{"245", "123", "5"}, rdb.Do(ctx, "SIREVRANGE", "mysi", 0, 3).Val())
+		require.EqualValues(t, []interface{}{"4", "3", "2"}, rdb.Do(ctx, "SIREVRANGE", "mysi", 0, 3, "cursor", 5).Val())
+		require.EqualValues(t, []interface{}{"245"}, rdb.Do(ctx, "SIRANGE", "mysi", 0, 3, "cursor", 123).Val())
+		require.EqualValues(t, []interface{}{"1", "2", "3", "4"}, rdb.Do(ctx, "SIRANGEBYVALUE", "mysi", 1, "(5").Val())
+		require.EqualValues(t, []interface{}{"5", "4", "3", "2"}, rdb.Do(ctx, "SIREVRANGEBYVALUE", "mysi", 5, "(1").Val())
+		require.EqualValues(t, []interface{}{int64(1), int64(0), int64(1)}, rdb.Do(ctx, "SIEXISTS", "mysi", 1, 88, 2).Val())
+		require.EqualValues(t, 1, rdb.Do(ctx, "SIREM", "mysi", 2).Val())
+	})
+
+}
diff --git a/tests/tcl/tests/test_helper.tcl b/tests/tcl/tests/test_helper.tcl
index ab97b52..8b1a521 100644
--- a/tests/tcl/tests/test_helper.tcl
+++ b/tests/tcl/tests/test_helper.tcl
@@ -41,7 +41,6 @@ set ::all_tests {
     unit/type/set
     unit/type/zset
     unit/type/hash
-    unit/type/sint
     unit/type/bitmap
     unit/type/stream
     unit/multi
diff --git a/tests/tcl/tests/unit/type/sint.tcl b/tests/tcl/tests/unit/type/sint.tcl
deleted file mode 100644
index ad72873..0000000
--- a/tests/tcl/tests/unit/type/sint.tcl
+++ /dev/null
@@ -1,34 +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.
-
-start_server {tags {"sorted-int"}} {
-    test {basic function of sint} {
-        assert_equal 1 [r SIADD mysi 1]
-        assert_equal 1 [r SIADD mysi 2]
-        assert_equal 0 [r SIADD mysi 2]
-        assert_equal 5 [r SIADD mysi 3 4 5 123 245]
-
-        assert_equal 7 [r SICARD mysi]
-        assert_equal {245 123 5} [r SIREVRANGE mysi 0 3]
-        assert_equal {4 3 2} [r SIREVRANGE mysi 0 3 cursor 5]
-        assert_equal {245} [r SIRANGE mysi 0 3 cursor 123]
-        assert_equal {1 2 3 4} [r SIRANGEBYVALUE mysi 1 (5]
-        assert_equal {5 4 3 2} [r SIREVRANGEBYVALUE mysi 5 (1]
-        assert_equal {1 0 1} [r SIEXISTS mysi 1 88 2]
-        assert_equal {1} [r SIREM mysi 2]
-    }
-}