MCPcopy
hub / github.com/stretchr/testify / TestIsNonIncreasing

Function TestIsNonIncreasing

assert/assertion_order_test.go:55–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func TestIsNonIncreasing(t *testing.T) {
56 t.Parallel()
57
58 mockT := new(testing.T)
59
60 if !IsNonIncreasing(mockT, []int{2, 1}) {
61 t.Error("IsNonIncreasing should return true")
62 }
63
64 if !IsNonIncreasing(mockT, []int{5, 4, 4, 3, 2, 1}) {
65 t.Error("IsNonIncreasing should return true")
66 }
67
68 if !IsNonIncreasing(mockT, []int{1, 1}) {
69 t.Error("IsNonIncreasing should return true")
70 }
71
72 if IsNonIncreasing(mockT, []int{1, 2}) {
73 t.Error("IsNonIncreasing should return false")
74 }
75
76 // Check error report
77 for _, currCase := range []struct {
78 collection interface{}
79 msg string
80 }{
81 {collection: []string{"a", "b"}, msg: `"a" is not greater than or equal to "b"`},
82 {collection: []int{1, 2}, msg: `"1" is not greater than or equal to "2"`},
83 {collection: []int{1, 2, 7, 6, 5, 4, 3}, msg: `"1" is not greater than or equal to "2"`},
84 {collection: []int{5, 4, 3, 1, 2}, msg: `"1" is not greater than or equal to "2"`},
85 {collection: []int8{1, 2}, msg: `"1" is not greater than or equal to "2"`},
86 {collection: []int16{1, 2}, msg: `"1" is not greater than or equal to "2"`},
87 {collection: []int32{1, 2}, msg: `"1" is not greater than or equal to "2"`},
88 {collection: []int64{1, 2}, msg: `"1" is not greater than or equal to "2"`},
89 {collection: []uint8{1, 2}, msg: `"1" is not greater than or equal to "2"`},
90 {collection: []uint16{1, 2}, msg: `"1" is not greater than or equal to "2"`},
91 {collection: []uint32{1, 2}, msg: `"1" is not greater than or equal to "2"`},
92 {collection: []uint64{1, 2}, msg: `"1" is not greater than or equal to "2"`},
93 {collection: []float32{1.23, 2.34}, msg: `"1.23" is not greater than or equal to "2.34"`},
94 {collection: []float64{1.23, 2.34}, msg: `"1.23" is not greater than or equal to "2.34"`},
95 } {
96 out := &outputT{buf: bytes.NewBuffer(nil)}
97 False(t, IsNonIncreasing(out, currCase.collection))
98 Contains(t, out.buf.String(), currCase.msg)
99 }
100}
101
102func TestIsDecreasing(t *testing.T) {
103 t.Parallel()

Callers

nothing calls this directly

Calls 5

IsNonIncreasingFunction · 0.70
FalseFunction · 0.70
ContainsFunction · 0.70
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected