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

Function TestWithinDuration

assert/assertions_test.go:2233–2251  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2231}
2232
2233func TestWithinDuration(t *testing.T) {
2234 t.Parallel()
2235
2236 mockT := new(testing.T)
2237 a := time.Now()
2238 b := a.Add(10 * time.Second)
2239
2240 True(t, WithinDuration(mockT, a, b, 10*time.Second), "A 10s difference is within a 10s time difference")
2241 True(t, WithinDuration(mockT, b, a, 10*time.Second), "A 10s difference is within a 10s time difference")
2242
2243 False(t, WithinDuration(mockT, a, b, 9*time.Second), "A 10s difference is not within a 9s time difference")
2244 False(t, WithinDuration(mockT, b, a, 9*time.Second), "A 10s difference is not within a 9s time difference")
2245
2246 False(t, WithinDuration(mockT, a, b, -9*time.Second), "A 10s difference is not within a 9s time difference")
2247 False(t, WithinDuration(mockT, b, a, -9*time.Second), "A 10s difference is not within a 9s time difference")
2248
2249 False(t, WithinDuration(mockT, a, b, -11*time.Second), "A 10s difference is not within a 9s time difference")
2250 False(t, WithinDuration(mockT, b, a, -11*time.Second), "A 10s difference is not within a 9s time difference")
2251}
2252
2253func TestWithinRange(t *testing.T) {
2254 t.Parallel()

Callers

nothing calls this directly

Calls 3

TrueFunction · 0.70
WithinDurationFunction · 0.70
FalseFunction · 0.70

Tested by

no test coverage detected