TestSpec_PublicAPI_MapKeys validates the documented behavior of MapKeys as described in the sliceutil README.md specification.
(t *testing.T)
| 48 | // TestSpec_PublicAPI_MapKeys validates the documented behavior of MapKeys |
| 49 | // as described in the sliceutil README.md specification. |
| 50 | func TestSpec_PublicAPI_MapKeys(t *testing.T) { |
| 51 | t.Run("returns all map keys as a slice", func(t *testing.T) { |
| 52 | m := map[string]int{"a": 1, "b": 2} |
| 53 | keys := MapKeys(m) |
| 54 | assert.ElementsMatch(t, []string{"a", "b"}, keys, "MapKeys should return all map keys (order not guaranteed)") |
| 55 | }) |
| 56 | |
| 57 | t.Run("returns empty slice for empty map", func(t *testing.T) { |
| 58 | m := map[string]int{} |
| 59 | keys := MapKeys(m) |
| 60 | assert.Empty(t, keys, "MapKeys of empty map should return empty slice") |
| 61 | }) |
| 62 | } |
| 63 | |
| 64 | // TestSpec_PublicAPI_FilterMapKeys validates the documented behavior of |
| 65 | // FilterMapKeys as described in the sliceutil README.md specification. |