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

Function TestPositive

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

Source from the content-addressed store, hash-verified

313}
314
315func TestPositive(t *testing.T) {
316 t.Parallel()
317
318 mockT := new(testing.T)
319
320 if !Positive(mockT, 1) {
321 t.Error("Positive should return true")
322 }
323
324 if !Positive(mockT, 1.23) {
325 t.Error("Positive should return true")
326 }
327
328 if Positive(mockT, -1) {
329 t.Error("Positive should return false")
330 }
331
332 if Positive(mockT, -1.23) {
333 t.Error("Positive should return false")
334 }
335
336 // Check error report
337 for _, currCase := range []struct {
338 e interface{}
339 msg string
340 }{
341 {e: int(-1), msg: `"-1" is not positive`},
342 {e: int8(-1), msg: `"-1" is not positive`},
343 {e: int16(-1), msg: `"-1" is not positive`},
344 {e: int32(-1), msg: `"-1" is not positive`},
345 {e: int64(-1), msg: `"-1" is not positive`},
346 {e: float32(-1.23), msg: `"-1.23" is not positive`},
347 {e: float64(-1.23), msg: `"-1.23" is not positive`},
348 } {
349 out := &outputT{buf: bytes.NewBuffer(nil)}
350 False(t, Positive(out, currCase.e))
351 Contains(t, out.buf.String(), currCase.msg)
352 Contains(t, out.helpers, "github.com/stretchr/testify/assert.Positive")
353 }
354}
355
356func TestNegative(t *testing.T) {
357 t.Parallel()

Callers

nothing calls this directly

Calls 5

PositiveFunction · 0.70
FalseFunction · 0.70
ContainsFunction · 0.70
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected