MCPcopy
hub / github.com/expr-lang/expr / TestIsNonDecreasing

Function TestIsNonDecreasing

internal/testify/assert/assertion_order_test.go:143–186  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…