1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-09 07:02:29 +08:00

feat: add KeysBy function

This commit is contained in:
dudaodong
2023-02-17 11:40:20 +08:00
parent 572e53aa14
commit e71cecefea
2 changed files with 30 additions and 0 deletions

View File

@@ -41,6 +41,24 @@ func TestValues(t *testing.T) {
assert.Equal([]string{"a", "a", "b", "c", "d"}, values)
}
func TestKeysBy(t *testing.T) {
assert := internal.NewAssert(t, "TestKeysBy")
m := map[int]string{
1: "a",
2: "a",
3: "b",
}
keys := KeysBy(m, func(n int) int {
return n + 1
})
sort.Ints(keys)
assert.Equal([]int{2, 3, 4}, keys)
}
func TestMerge(t *testing.T) {
assert := internal.NewAssert(t, "TestMerge")