MCPcopy Create free account
hub / github.com/adam-hanna/arrayOperations / TestReduce

Function TestReduce

arrayOperations_unit_test.go:102–115  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

100}
101
102func TestReduce(t *testing.T) {
103 arr := []string{"cat", "dog", "cat", "cow"}
104 initialState := make(map[string]int)
105 finalState := Reduce(arr, countAnimals, initialState)
106 expected := map[string]int{
107 "cat": 2,
108 "dog": 1,
109 "cow": 1,
110 }
111
112 if !reflect.DeepEqual(finalState, expected) {
113 t.Errorf("expected %v, received %v", expected, finalState)
114 }
115}
116
117func guard(i int) bool {
118 return i%2 == 0

Callers

nothing calls this directly

Calls 1

ReduceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…