MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / TestMax

Function TestMax

math/max/max_test.go:5–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3import "testing"
4
5func TestMax(t *testing.T) {
6 testCases := []struct {
7 name string
8 left int
9 right int
10 max int
11 }{
12 {
13 name: "Left is max",
14 left: 10,
15 right: 9,
16 max: 10,
17 },
18 {
19 name: "right is max",
20 left: 1,
21 right: 10,
22 max: 10,
23 },
24 }
25
26 for _, test := range testCases {
27 t.Run(test.name, func(t *testing.T) {
28 returnedMax := Int(test.left, test.right)
29 if returnedMax != test.max {
30 t.Errorf("Failed test %s\n\tleft: %v, right: %v, max: %v but received: %v",
31 test.name, test.left, test.right, test.max, returnedMax)
32 }
33 })
34 }
35}
36
37func TestMaxOfThree(t *testing.T) {
38 testCases := []struct {

Callers

nothing calls this directly

Calls 1

IntFunction · 0.70

Tested by

no test coverage detected