(t *testing.T)
| 6 | ) |
| 7 | |
| 8 | func TestIsIncreasing(t *testing.T) { |
| 9 | t.Parallel() |
| 10 | |
| 11 | mockT := new(testing.T) |
| 12 | |
| 13 | if !IsIncreasing(mockT, []int{1, 2}) { |
| 14 | t.Error("IsIncreasing should return true") |
| 15 | } |
| 16 | |
| 17 | if !IsIncreasing(mockT, []int{1, 2, 3, 4, 5}) { |
| 18 | t.Error("IsIncreasing should return true") |
| 19 | } |
| 20 | |
| 21 | if IsIncreasing(mockT, []int{1, 1}) { |
| 22 | t.Error("IsIncreasing should return false") |
| 23 | } |
| 24 | |
| 25 | if IsIncreasing(mockT, []int{2, 1}) { |
| 26 | t.Error("IsIncreasing should return false") |
| 27 | } |
| 28 | |
| 29 | // Check error report |
| 30 | for _, currCase := range []struct { |
| 31 | collection interface{} |
| 32 | msg string |
| 33 | }{ |
| 34 | {collection: []string{"b", "a"}, msg: `"b" is not less than "a"`}, |
| 35 | {collection: []int{2, 1}, msg: `"2" is not less than "1"`}, |
| 36 | {collection: []int{2, 1, 3, 4, 5, 6, 7}, msg: `"2" is not less than "1"`}, |
| 37 | {collection: []int{-1, 0, 2, 1}, msg: `"2" is not less than "1"`}, |
| 38 | {collection: []int8{2, 1}, msg: `"2" is not less than "1"`}, |
| 39 | {collection: []int16{2, 1}, msg: `"2" is not less than "1"`}, |
| 40 | {collection: []int32{2, 1}, msg: `"2" is not less than "1"`}, |
| 41 | {collection: []int64{2, 1}, msg: `"2" is not less than "1"`}, |
| 42 | {collection: []uint8{2, 1}, msg: `"2" is not less than "1"`}, |
| 43 | {collection: []uint16{2, 1}, msg: `"2" is not less than "1"`}, |
| 44 | {collection: []uint32{2, 1}, msg: `"2" is not less than "1"`}, |
| 45 | {collection: []uint64{2, 1}, msg: `"2" is not less than "1"`}, |
| 46 | {collection: []float32{2.34, 1.23}, msg: `"2.34" is not less than "1.23"`}, |
| 47 | {collection: []float64{2.34, 1.23}, msg: `"2.34" is not less than "1.23"`}, |
| 48 | } { |
| 49 | out := &outputT{buf: bytes.NewBuffer(nil)} |
| 50 | False(t, IsIncreasing(out, currCase.collection)) |
| 51 | Contains(t, out.buf.String(), currCase.msg) |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | func TestIsNonIncreasing(t *testing.T) { |
| 56 | t.Parallel() |
nothing calls this directly
no test coverage detected