Compare commits

...

2 Commits

Author SHA1 Message Date
sweep-ai[bot]
827936067a Merge main into sweep/add-unit-test-remove-repeated-elements 2023-10-16 03:40:13 +00:00
sweep-ai[bot]
e13714ef5d feat: Add unit test for RemoveRepeatedElementsInLi 2023-10-13 14:37:23 +00:00

41
tests/user_test.go Normal file
View File

@@ -0,0 +1,41 @@
package cache_test
import (
"reflect"
"testing"
"github.com/openimsdk/open-im-server/v3/pkg/common/db/cache"
)
func TestRemoveRepeatedElementsInList(t *testing.T) {
testCases := []struct {
name string
input []string
expected []string
}{
{
name: "empty list",
input: []string{},
expected: []string{},
},
{
name: "list with no duplicates",
input: []string{"a", "b", "c"},
expected: []string{"a", "b", "c"},
},
{
name: "list with duplicates",
input: []string{"a", "b", "a", "c", "b"},
expected: []string{"a", "b", "c"},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
actual := cache.RemoveRepeatedElementsInList(tc.input)
if !reflect.DeepEqual(actual, tc.expected) {
t.Errorf("RemoveRepeatedElementsInList(%v) = %v; want %v", tc.input, actual, tc.expected)
}
})
}
}