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

feat: add ListToMap for list

This commit is contained in:
dudaodong
2023-02-06 11:06:46 +08:00
parent 1fe4cdc429
commit c35bda6a65
2 changed files with 24 additions and 0 deletions

View File

@@ -447,3 +447,16 @@ func TestIterator(t *testing.T) {
assert.Equal([]int{1, 2, 3, 4}, rs)
}
func TestListToMap(t *testing.T) {
assert := internal.NewAssert(t, "ListToMap")
list := NewList([]int{1, 2, 3, 4})
result := ListToMap(list, func(n int) (int, bool) {
return n, n > 1
})
expected := map[int]bool{1: false, 2: true, 3: true, 4: true}
assert.Equal(expected, result)
}