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

Function WithinDuration

internal/testify/assert/assertions.go:1286–1297  ·  view source on GitHub ↗

WithinDuration asserts that the two times are within duration delta of each other. assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)

(t TestingT, expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

1284//
1285// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
1286func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
1287 if h, ok := t.(tHelper); ok {
1288 h.Helper()
1289 }
1290
1291 dt := expected.Sub(actual)
1292 if dt < -delta || dt > delta {
1293 return Fail(t, fmt.Sprintf("Max difference between %v and %v allowed is %v, but difference was %v", expected, actual, delta, dt), msgAndArgs...)
1294 }
1295
1296 return true
1297}
1298
1299// WithinRange asserts that a time is within a time range (inclusive).
1300//

Callers 4

WithinDurationFunction · 0.92
WithinDurationfFunction · 0.70
TestWithinDurationFunction · 0.70
WithinDurationMethod · 0.70

Calls 4

SubMethod · 0.80
SprintfMethod · 0.80
FailFunction · 0.70
HelperMethod · 0.45

Tested by 1

TestWithinDurationFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…