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

test: add unit test for Keys and Values func

This commit is contained in:
dudaodong
2022-03-30 17:45:17 +08:00
parent ae54c8db6f
commit 1af8fe8daf
2 changed files with 44 additions and 2 deletions

42
maputil/map_test.go Normal file
View File

@@ -0,0 +1,42 @@
package maputil
import (
"sort"
"testing"
"github.com/duke-git/lancet/v2/internal"
)
func TestKeys(t *testing.T) {
assert := internal.NewAssert(t, "TestKeys")
m := map[int]string{
1: "a",
2: "a",
3: "b",
4: "c",
5: "d",
}
keys := Keys(m)
sort.Ints(keys)
assert.Equal([]int{1, 2, 3, 4, 5}, keys)
}
func TestValues(t *testing.T) {
assert := internal.NewAssert(t, "TestValues")
m := map[int]string{
1: "a",
2: "a",
3: "b",
4: "c",
5: "d",
}
values := Values(m)
sort.Strings(values)
assert.Equal([]string{"a", "a", "b", "c", "d"}, values)
}