Skip to content

Commit

Permalink
Add tests for Keys and Values on defined types
Browse files Browse the repository at this point in the history
  • Loading branch information
creachadair committed Jan 27, 2025
1 parent 1638587 commit 116a508
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions mapset/mapset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,15 @@ func TestKeys(t *testing.T) {
1: "red", 2: "orange", 3: "yellow",
}), 1, 2, 3)
})
t.Run("MapType", func(t *testing.T) {
type M map[string]int
check(t, mapset.Keys(M{"foo": 1, "bar": 2, "baz": 3}),
"foo", "bar", "baz")
})
t.Run("Set", func(t *testing.T) {
check(t, mapset.Keys(mapset.New("x", "y", "z")),
"x", "y", "z")
})
}

func TestValues(t *testing.T) {
Expand All @@ -334,6 +343,15 @@ func TestValues(t *testing.T) {
"red": 1, "green": 1, "blue": 2, "white": 2,
}), 1, 2)
})
t.Run("MapType", func(t *testing.T) {
type M map[string]int
check(t, mapset.Values(M{"foo": 1, "bar": 2, "baz": 3}),
1, 2, 3)
})
t.Run("Set", func(t *testing.T) {
check(t, mapset.Values(mapset.New("x", "y", "z")),
struct{}{})
})
}

func TestAppend(t *testing.T) {
Expand Down

0 comments on commit 116a508

Please sign in to comment.