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

Function TestFilter

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

Source from the content-addressed store, hash-verified

23 })
24}
25func TestFilter(t *testing.T) {
26 t.Run("empty slice", func(t *testing.T) {
27 require := require.New(t)
28
29 var s []int
30 got := Filter(s, func(i int) bool { return i%2 == 0 })
31 require.Equal(got, []int{})
32 })
33 t.Run("non-empty slice", func(t *testing.T) {
34 require := require.New(t)
35
36 s := []int{1, 2, 3}
37 got := Filter(s, func(i int) bool { return i%2 == 0 })
38 require.Equal(got, []int{2})
39 })
40}
41
42func TestReverse(t *testing.T) {
43 require := require.New(t)

Callers

nothing calls this directly

Calls 2

FilterFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected