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

Function TestIsNonDecreasing

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

Source from the content-addressed store, hash-verified

147}
148
149func TestIsNonDecreasing(t *testing.T) {
150 t.Parallel()
151
152 mockT := new(testing.T)
153
154 if !IsNonDecreasing(mockT, []int{1, 2}) {
155 t.Error("IsNonDecreasing should return true")
156 }
157
158 if !IsNonDecreasing(mockT, []int{1, 1, 2, 3, 4, 5}) {
159 t.Error("IsNonDecreasing should return true")
160 }
161
162 if !IsNonDecreasing(mockT, []int{1, 1}) {
163 t.Error("IsNonDecreasing should return false")
164 }
165
166 if IsNonDecreasing(mockT, []int{2, 1}) {
167 t.Error("IsNonDecreasing should return false")
168 }
169
170 // Check error report
171 for _, currCase := range []struct {
172 collection interface{}
173 msg string
174 }{
175 {collection: []string{"b", "a"}, msg: `"b" is not less than or equal to "a"`},
176 {collection: []int{2, 1}, msg: `"2" is not less than or equal to "1"`},
177 {collection: []int{2, 1, 3, 4, 5, 6, 7}, msg: `"2" is not less than or equal to "1"`},
178 {collection: []int{-1, 0, 2, 1}, msg: `"2" is not less than or equal to "1"`},
179 {collection: []int8{2, 1}, msg: `"2" is not less than or equal to "1"`},
180 {collection: []int16{2, 1}, msg: `"2" is not less than or equal to "1"`},
181 {collection: []int32{2, 1}, msg: `"2" is not less than or equal to "1"`},
182 {collection: []int64{2, 1}, msg: `"2" is not less than or equal to "1"`},
183 {collection: []uint8{2, 1}, msg: `"2" is not less than or equal to "1"`},
184 {collection: []uint16{2, 1}, msg: `"2" is not less than or equal to "1"`},
185 {collection: []uint32{2, 1}, msg: `"2" is not less than or equal to "1"`},
186 {collection: []uint64{2, 1}, msg: `"2" is not less than or equal to "1"`},
187 {collection: []float32{2.34, 1.23}, msg: `"2.34" is not less than or equal to "1.23"`},
188 {collection: []float64{2.34, 1.23}, msg: `"2.34" is not less than or equal to "1.23"`},
189 } {
190 out := &outputT{buf: bytes.NewBuffer(nil)}
191 False(t, IsNonDecreasing(out, currCase.collection))
192 Contains(t, out.buf.String(), currCase.msg)
193 }
194}
195
196func TestOrderingMsgAndArgsForwarding(t *testing.T) {
197 t.Parallel()

Callers

nothing calls this directly

Calls 5

IsNonDecreasingFunction · 0.70
FalseFunction · 0.70
ContainsFunction · 0.70
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected