mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 02:26:42 +00:00
- Add `Chunk` to split slices into groups of size n. - Add `ContainsBy` for predicate-based containment checks. - Add `UniqueBy` to deduplicate slices by key selector. - Add `ParallelMap` for concurrent mapping with context and error handling. - Add `maps.Keys` and `maps.Values` helpers for extracting map keys/values. - Update README and docs for new features. - Refactor `Contains` to use `slices.Contains`.
22 lines
442 B
Go
22 lines
442 B
Go
package maps_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
m "github.com/rjNemo/underscore/maps"
|
|
)
|
|
|
|
func TestKeysValues(t *testing.T) {
|
|
in := map[int]string{1: "a", 2: "b", 3: "c"}
|
|
ks := m.Keys(in)
|
|
vs := m.Values(in)
|
|
|
|
// Order is unspecified; verify content and lengths.
|
|
assert.Len(t, ks, 3)
|
|
assert.ElementsMatch(t, []int{1, 2, 3}, ks)
|
|
|
|
assert.Len(t, vs, 3)
|
|
assert.ElementsMatch(t, []string{"a", "b", "c"}, vs)
|
|
}
|