From 5f8764b82a3e13018a7257f15cfa19ba6730f0d6 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Fri, 13 Oct 2023 14:38:20 +0000 Subject: [PATCH] feat: Add unit test for RemoveRepeatedElementsInLi --- tests/user_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/user_test.go diff --git a/tests/user_test.go b/tests/user_test.go new file mode 100644 index 000000000..a8b5602c8 --- /dev/null +++ b/tests/user_test.go @@ -0,0 +1,33 @@ +package cache + +import ( + "testing" + "reflect" +) + +func TestRemoveRepeatedElementsInList(t *testing.T) { + testCases := []struct { + input []string + expected []string + }{ + { + input: []string{}, + expected: []string{}, + }, + { + input: []string{"a", "b", "c"}, + expected: []string{"a", "b", "c"}, + }, + { + input: []string{"a", "a", "b", "b", "c", "c"}, + expected: []string{"a", "b", "c"}, + }, + } + + for _, testCase := range testCases { + result := RemoveRepeatedElementsInList(testCase.input) + if !reflect.DeepEqual(result, testCase.expected) { + t.Errorf("RemoveRepeatedElementsInList(%v) = %v; want %v", testCase.input, result, testCase.expected) + } + } +}