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

Function TestLessOrEqual

assert/assertion_compare_test.go:269–313  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

267}
268
269func TestLessOrEqual(t *testing.T) {
270 t.Parallel()
271
272 mockT := new(testing.T)
273
274 if !LessOrEqual(mockT, 1, 2) {
275 t.Error("LessOrEqual should return true")
276 }
277
278 if !LessOrEqual(mockT, 1, 1) {
279 t.Error("LessOrEqual should return true")
280 }
281
282 if LessOrEqual(mockT, 2, 1) {
283 t.Error("LessOrEqual should return false")
284 }
285
286 // Check error report
287 for _, currCase := range []struct {
288 less interface{}
289 greater interface{}
290 msg string
291 }{
292 {less: "a", greater: "b", msg: `"b" is not less than or equal to "a"`},
293 {less: int(1), greater: int(2), msg: `"2" is not less than or equal to "1"`},
294 {less: int8(1), greater: int8(2), msg: `"2" is not less than or equal to "1"`},
295 {less: int16(1), greater: int16(2), msg: `"2" is not less than or equal to "1"`},
296 {less: int32(1), greater: int32(2), msg: `"2" is not less than or equal to "1"`},
297 {less: int64(1), greater: int64(2), msg: `"2" is not less than or equal to "1"`},
298 {less: uint8(1), greater: uint8(2), msg: `"2" is not less than or equal to "1"`},
299 {less: uint16(1), greater: uint16(2), msg: `"2" is not less than or equal to "1"`},
300 {less: uint32(1), greater: uint32(2), msg: `"2" is not less than or equal to "1"`},
301 {less: uint64(1), greater: uint64(2), msg: `"2" is not less than or equal to "1"`},
302 {less: float32(1.23), greater: float32(2.34), msg: `"2.34" is not less than or equal to "1.23"`},
303 {less: float64(1.23), greater: float64(2.34), msg: `"2.34" is not less than or equal to "1.23"`},
304 {less: uintptr(1), greater: uintptr(2), msg: `"2" is not less than or equal to "1"`},
305 {less: time.Time{}, greater: time.Time{}.Add(time.Hour), msg: `"0001-01-01 01:00:00 +0000 UTC" is not less than or equal to "0001-01-01 00:00:00 +0000 UTC"`},
306 {less: []byte{1, 1}, greater: []byte{1, 2}, msg: `"[1 2]" is not less than or equal to "[1 1]"`},
307 } {
308 out := &outputT{buf: bytes.NewBuffer(nil)}
309 False(t, LessOrEqual(out, currCase.greater, currCase.less))
310 Contains(t, out.buf.String(), currCase.msg)
311 Contains(t, out.helpers, "github.com/stretchr/testify/assert.LessOrEqual")
312 }
313}
314
315func TestPositive(t *testing.T) {
316 t.Parallel()

Callers

nothing calls this directly

Calls 5

LessOrEqualFunction · 0.70
FalseFunction · 0.70
ContainsFunction · 0.70
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected