MCPcopy Index your code
hub / github.com/adam-hanna/arrayOperations / TestFindOne

Function TestFindOne

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

Source from the content-addressed store, hash-verified

62}
63
64func TestFindOne(t *testing.T) {
65 t.Run("has elements", func(t *testing.T) {
66 arr := []int{1, 2, 3, 4}
67 el, ok := FindOne(arr, findOneGuard)
68 expected := 2
69
70 if !ok {
71 t.Errorf("expected %v, received %v", true, ok)
72 }
73 if el != expected {
74 t.Errorf("expected %v, received %v", expected, el)
75 }
76 })
77 t.Run("no elements", func(t *testing.T) {
78 arr := []int{1, 3, 5}
79 el, ok := FindOne(arr, findOneGuard)
80 expected := 0
81
82 if ok {
83 t.Errorf("expected %v, received %v", false, ok)
84 }
85 if el != expected {
86 t.Errorf("expected %v, received %v", expected, el)
87 }
88 })
89}
90
91func countAnimals(state map[string]int, animal string) map[string]int {
92 count, ok := state[animal]

Callers

nothing calls this directly

Calls 1

FindOneFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…