package slice import "testing" func TestRemoveRepeatElement(t *testing.T) { strSlice := []string{"1", "2", "1", "3", "2", "4", "3"} intSlice := []int{1, 2, 1, 3, 2, 4, 3} strSliceRemovedRepeatElement := RemoveRepeatElement(strSlice) if strSliceRemovedRepeatElement[0] != "1" || strSliceRemovedRepeatElement[1] != "2" || strSliceRemovedRepeatElement[2] != "3" || strSliceRemovedRepeatElement[3] != "4" { t.Fatal("字符串slice移除元素后不正确") } intSliceRemovedRepeatElement := RemoveRepeatElement(intSlice) if intSliceRemovedRepeatElement[0] != 1 || intSliceRemovedRepeatElement[1] != 2 || intSliceRemovedRepeatElement[2] != 3 || intSliceRemovedRepeatElement[3] != 4 { t.Fatal("整型slice移除元素后不正确") } }