| 3 | import "testing" |
| 4 | |
| 5 | func 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 | |
| 37 | func TestMaxOfThree(t *testing.T) { |
| 38 | testCases := []struct { |