1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| package main
import ( "testing"
"github.com/bmizerany/assert" )
func TestMissNumber(t *testing.T) { t.Run("首", func(t *testing.T) { m := missingNumber([]int{1, 2, 3}) assert.Equal(t, 0, m, 0) }) t.Run("尾", func(t *testing.T) { m := missingNumber([]int{0, 1, 2}) assert.Equal(t, 3, m, 3) }) t.Run("中间", func(t *testing.T) { m := missingNumber([]int{0, 1, 3}) assert.Equal(t, 2, m, 2) }) }
func TestMissNumber1(t *testing.T) { t.Run("首", func(t *testing.T) { m := missingNumber1([]int{1, 2, 3}) assert.Equal(t, 0, m, 0) }) t.Run("尾", func(t *testing.T) { m := missingNumber1([]int{0, 1, 2}) assert.Equal(t, 3, m, 3) }) t.Run("中间", func(t *testing.T) { m := missingNumber1([]int{0, 1, 3}) assert.Equal(t, 2, m, 2) }) }
func TestMissNumber2(t *testing.T) { t.Run("首", func(t *testing.T) { m := missingNumber2([]int{1, 2, 3}) assert.Equal(t, 0, m, 0) }) t.Run("尾", func(t *testing.T) { m := missingNumber2([]int{0, 1, 2}) assert.Equal(t, 3, m, 3) }) t.Run("中间", func(t *testing.T) { m := missingNumber2([]int{0, 1, 3}) assert.Equal(t, 2, m, 2) }) }
|