MCPcopy Index your code
hub / github.com/expr-lang/expr / WithinRange

Function WithinRange

internal/testify/assert/assertions.go:1302–1318  ·  view source on GitHub ↗

WithinRange asserts that a time is within a time range (inclusive). assert.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))

(t TestingT, actual, start, end time.Time, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

1300//
1301// assert.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
1302func WithinRange(t TestingT, actual, start, end time.Time, msgAndArgs ...interface{}) bool {
1303 if h, ok := t.(tHelper); ok {
1304 h.Helper()
1305 }
1306
1307 if end.Before(start) {
1308 return Fail(t, "Start should be before end", msgAndArgs...)
1309 }
1310
1311 if actual.Before(start) {
1312 return Fail(t, fmt.Sprintf("Time %v expected to be in time range %v to %v, but is before the range", actual, start, end), msgAndArgs...)
1313 } else if actual.After(end) {
1314 return Fail(t, fmt.Sprintf("Time %v expected to be in time range %v to %v, but is after the range", actual, start, end), msgAndArgs...)
1315 }
1316
1317 return true
1318}
1319
1320func toFloat(x interface{}) (float64, bool) {
1321 var xf float64

Callers 4

WithinRangeFunction · 0.92
WithinRangefFunction · 0.70
TestWithinRangeFunction · 0.70
WithinRangeMethod · 0.70

Calls 5

BeforeMethod · 0.80
SprintfMethod · 0.80
AfterMethod · 0.80
FailFunction · 0.70
HelperMethod · 0.45

Tested by 1

TestWithinRangeFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…