(t *testing.T)
| 102 | } |
| 103 | |
| 104 | func TestDeduplicate(t *testing.T) { |
| 105 | tests := []struct { |
| 106 | name string |
| 107 | slice []string |
| 108 | expected []string |
| 109 | }{ |
| 110 | { |
| 111 | name: "nil slice returns empty slice", |
| 112 | slice: nil, |
| 113 | expected: []string{}, |
| 114 | }, |
| 115 | { |
| 116 | name: "empty slice returns empty slice", |
| 117 | slice: []string{}, |
| 118 | expected: []string{}, |
| 119 | }, |
| 120 | { |
| 121 | name: "no duplicates returns same elements in order", |
| 122 | slice: []string{"apple", "banana", "cherry"}, |
| 123 | expected: []string{"apple", "banana", "cherry"}, |
| 124 | }, |
| 125 | { |
| 126 | name: "partial duplicates removed preserving first occurrence order", |
| 127 | slice: []string{"apple", "banana", "apple", "cherry", "banana"}, |
| 128 | expected: []string{"apple", "banana", "cherry"}, |
| 129 | }, |
| 130 | { |
| 131 | name: "all duplicates returns single element", |
| 132 | slice: []string{"apple", "apple", "apple"}, |
| 133 | expected: []string{"apple"}, |
| 134 | }, |
| 135 | { |
| 136 | name: "single element", |
| 137 | slice: []string{"apple"}, |
| 138 | expected: []string{"apple"}, |
| 139 | }, |
| 140 | } |
| 141 | |
| 142 | for _, tt := range tests { |
| 143 | t.Run(tt.name, func(t *testing.T) { |
| 144 | result := Deduplicate(tt.slice) |
| 145 | assert.Equal(t, tt.expected, result, |
| 146 | "Deduplicate should remove duplicates from slice %v", tt.slice) |
| 147 | }) |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | func TestMapKeys(t *testing.T) { |
| 152 | t.Run("nil map returns empty slice", func(t *testing.T) { |
nothing calls this directly
no test coverage detected