| 149 | } |
| 150 | |
| 151 | func TestMapKeys(t *testing.T) { |
| 152 | t.Run("nil map returns empty slice", func(t *testing.T) { |
| 153 | result := MapKeys[string, int](nil) |
| 154 | assert.Empty(t, result, "MapKeys should return empty slice for nil map") |
| 155 | }) |
| 156 | |
| 157 | t.Run("empty map returns empty slice", func(t *testing.T) { |
| 158 | result := MapKeys(map[string]int{}) |
| 159 | assert.Empty(t, result, "MapKeys should return empty slice for empty map") |
| 160 | }) |
| 161 | |
| 162 | t.Run("returns all keys in any order", func(t *testing.T) { |
| 163 | m := map[string]int{"apple": 1, "banana": 2, "cherry": 3} |
| 164 | result := MapKeys(m) |
| 165 | assert.ElementsMatch(t, []string{"apple", "banana", "cherry"}, result, |
| 166 | "MapKeys should return all keys from map") |
| 167 | }) |
| 168 | |
| 169 | t.Run("single entry map", func(t *testing.T) { |
| 170 | m := map[string]struct{}{"only": {}} |
| 171 | result := MapKeys(m) |
| 172 | assert.Equal(t, []string{"only"}, result, |
| 173 | "MapKeys should return the single key from a one-entry map") |
| 174 | }) |
| 175 | } |
| 176 | |
| 177 | func TestFilterMapKeys(t *testing.T) { |
| 178 | t.Run("nil map returns empty slice", func(t *testing.T) { |