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

Function TestWithinDurationWrapper

assert/forward_assertions_test.go:470–489  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

468}
469
470func TestWithinDurationWrapper(t *testing.T) {
471 t.Parallel()
472
473 assert := New(t)
474 mockAssert := New(new(testing.T))
475 a := time.Now()
476 b := a.Add(10 * time.Second)
477
478 assert.True(mockAssert.WithinDuration(a, b, 10*time.Second), "A 10s difference is within a 10s time difference")
479 assert.True(mockAssert.WithinDuration(b, a, 10*time.Second), "A 10s difference is within a 10s time difference")
480
481 assert.False(mockAssert.WithinDuration(a, b, 9*time.Second), "A 10s difference is not within a 9s time difference")
482 assert.False(mockAssert.WithinDuration(b, a, 9*time.Second), "A 10s difference is not within a 9s time difference")
483
484 assert.False(mockAssert.WithinDuration(a, b, -9*time.Second), "A 10s difference is not within a 9s time difference")
485 assert.False(mockAssert.WithinDuration(b, a, -9*time.Second), "A 10s difference is not within a 9s time difference")
486
487 assert.False(mockAssert.WithinDuration(a, b, -11*time.Second), "A 10s difference is not within a 9s time difference")
488 assert.False(mockAssert.WithinDuration(b, a, -11*time.Second), "A 10s difference is not within a 9s time difference")
489}
490
491func TestInDeltaWrapper(t *testing.T) {
492 t.Parallel()

Callers

nothing calls this directly

Calls 4

NewFunction · 0.70
TrueMethod · 0.45
WithinDurationMethod · 0.45
FalseMethod · 0.45

Tested by

no test coverage detected