mirror of
https://github.com/duke-git/lancet.git
synced 2026-11-16 05:12:11 +08:00
test: add unit test for Keys and Values func
This commit is contained in:
1 parent
ae54c8db6f
commit
1af8fe8daf
2 files changed
+44
-2
No files matched your search
+2
-2
@@ -6,7 +6,7 @@ package maputil
|
||||
|
||||
// Keys returns a slice of the map's keys
|
||||
func Keys[K comparable, V any](m map[K]V) []K {
|
||||
keys := make([]K, len(m))
|
||||
keys := make([]K, 0, len(m))
|
||||
|
||||
for k := range m {
|
||||
keys = append(keys, k)
|
||||
@@ -17,7 +17,7 @@ func Keys[K comparable, V any](m map[K]V) []K {
|
||||
|
||||
// Values returns a slice of the map's values
|
||||
func Values[K comparable, V any](m map[K]V) []V {
|
||||
values := make([]V, len(m))
|
||||
values := make([]V, 0, len(m))
|
||||
|
||||
for _, v := range m {
|
||||
values = append(values, v)
|
||||
|
||||
Reference in new issue
Block a user