MCPcopy Create free account
hub / github.com/davecheney/pub / TestMap

Function TestMap

internal/algorithms/algorithms_test.go:9–24  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestMap(t *testing.T) {
10 t.Run("empty slice", func(t *testing.T) {
11 require := require.New(t)
12
13 var s []int
14 got := Map(s, func(i int) int { return i })
15 require.Equal(got, []int{})
16 })
17 t.Run("non-empty slice", func(t *testing.T) {
18 require := require.New(t)
19
20 s := []int{1, 2, 3}
21 got := Map(s, func(i int) int { return i * 2 })
22 require.Equal(got, []int{2, 4, 6})
23 })
24}
25func TestFilter(t *testing.T) {
26 t.Run("empty slice", func(t *testing.T) {
27 require := require.New(t)

Callers

nothing calls this directly

Calls 2

MapFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected