github.com/diamondburned/arikawa/v2@v2.1.0/internal/intmath/math_test.go (about) 1 package intmath 2 3 import "testing" 4 5 func TestMin(t *testing.T) { 6 testCases := []struct { 7 name string 8 a, b int 9 expect int 10 }{ 11 { 12 name: "first smaller", 13 a: 1, 14 b: 2, 15 expect: 1, 16 }, 17 { 18 name: "both equal", 19 a: 1, 20 b: 1, 21 expect: 1, 22 }, 23 { 24 name: "last smaller", 25 a: 2, 26 b: 1, 27 expect: 1, 28 }, 29 } 30 31 for _, c := range testCases { 32 t.Run(c.name, func(t *testing.T) { 33 actual := Min(c.a, c.b) 34 if c.expect != actual { 35 t.Errorf("expected min(%d, %d) to return %d, but did %d", c.a, c.b, c.expect, actual) 36 } 37 }) 38 } 39 }