(t *testing.T)
| 62 | } |
| 63 | |
| 64 | func 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 | |
| 91 | func countAnimals(state map[string]int, animal string) map[string]int { |
| 92 | count, ok := state[animal] |
nothing calls this directly
no test coverage detected
searching dependent graphs…