From 7788bd3a730fe48cdd71d993f095faad33e279db Mon Sep 17 00:00:00 2001 From: Ruan Moolman Date: Mon, 27 Jun 2022 14:31:27 +0200 Subject: [PATCH] Improve WithinRange example --- assert/assertion_format.go | 2 +- assert/assertion_forward.go | 4 ++-- assert/assertions.go | 2 +- require/require.go | 4 ++-- require/require_forward.go | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/assert/assertion_format.go b/assert/assertion_format.go index 5b5045084..d775a5590 100644 --- a/assert/assertion_format.go +++ b/assert/assertion_format.go @@ -738,7 +738,7 @@ func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta tim // WithinRangef asserts that a time is within a time range (inclusive). // -// assert.WithinRangef(t, time.Now(), time.Now(), time.Now(), "error message %s", "formatted") +// assert.WithinRangef(t, time.Now(), time.Now().Sub(time.Second()), time.Now().Add(time.Second()), "error message %s", "formatted") func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() diff --git a/assert/assertion_forward.go b/assert/assertion_forward.go index df6383671..95bce70da 100644 --- a/assert/assertion_forward.go +++ b/assert/assertion_forward.go @@ -1463,7 +1463,7 @@ func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta // WithinRange asserts that a time is within a time range (inclusive). // -// a.WithinRange(time.Now(), time.Now(), time.Now()) +// a.WithinRange(time.Now(), time.Now().Sub(time.Second()), time.Now().Add(time.Second())) func (a *Assertions) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1473,7 +1473,7 @@ func (a *Assertions) WithinRange(actual time.Time, start time.Time, end time.Tim // WithinRangef asserts that a time is within a time range (inclusive). // -// a.WithinRangef(time.Now(), time.Now(), time.Now(), "error message %s", "formatted") +// a.WithinRangef(time.Now(), time.Now().Sub(time.Second()), time.Now().Add(time.Second()), "error message %s", "formatted") func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() diff --git a/assert/assertions.go b/assert/assertions.go index 7d1357191..ff0e351f6 100644 --- a/assert/assertions.go +++ b/assert/assertions.go @@ -1111,7 +1111,7 @@ func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration, // WithinRange asserts that a time is within a time range (inclusive). // -// assert.WithinRange(t, time.Now(), time.Now(), time.Now()) +// assert.WithinRange(t, time.Now(), time.Now().Sub(time.Second()), time.Now().Add(time.Second())) func WithinRange(t TestingT, actual, start, end time.Time, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() diff --git a/require/require.go b/require/require.go index 941c33fea..c8cba094c 100644 --- a/require/require.go +++ b/require/require.go @@ -1866,7 +1866,7 @@ func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta tim // WithinRange asserts that a time is within a time range (inclusive). // -// assert.WithinRange(t, time.Now(), time.Now(), time.Now()) +// assert.WithinRange(t, time.Now(), time.Now().Sub(time.Second()), time.Now().Add(time.Second())) func WithinRange(t TestingT, actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1879,7 +1879,7 @@ func WithinRange(t TestingT, actual time.Time, start time.Time, end time.Time, m // WithinRangef asserts that a time is within a time range (inclusive). // -// assert.WithinRangef(t, time.Now(), time.Now(), time.Now(), "error message %s", "formatted") +// assert.WithinRangef(t, time.Now(), time.Now().Sub(time.Second()), time.Now().Add(time.Second()), "error message %s", "formatted") func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() diff --git a/require/require_forward.go b/require/require_forward.go index 2af8276a6..d47858de4 100644 --- a/require/require_forward.go +++ b/require/require_forward.go @@ -1464,7 +1464,7 @@ func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta // WithinRange asserts that a time is within a time range (inclusive). // -// a.WithinRange(time.Now(), time.Now(), time.Now()) +// a.WithinRange(time.Now(), time.Now().Sub(time.Second()), time.Now().Add(time.Second())) func (a *Assertions) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1474,7 +1474,7 @@ func (a *Assertions) WithinRange(actual time.Time, start time.Time, end time.Tim // WithinRangef asserts that a time is within a time range (inclusive). // -// a.WithinRangef(time.Now(), time.Now(), time.Now(), "error message %s", "formatted") +// a.WithinRangef(time.Now(), time.Now().Sub(time.Second()), time.Now().Add(time.Second()), "error message %s", "formatted") func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper()