diff --git a/assert/assertions.go b/assert/assertions.go index 4c03834..c632bc7 100644 --- a/assert/assertions.go +++ b/assert/assertions.go @@ -886,6 +886,8 @@ func toFloat(x interface{}) (float64, bool) { xf = float64(xn) case float64: xf = float64(xn) + case time.Duration: + xf = float64(xn) default: xok = false } diff --git a/assert/assertions_test.go b/assert/assertions_test.go index cd67ee6..bb2b59f 100644 --- a/assert/assertions_test.go +++ b/assert/assertions_test.go @@ -1045,6 +1045,7 @@ func TestInEpsilon(t *testing.T) { {uint64(100), uint8(101), 0.01}, {0.1, -0.1, 2}, {0.1, 0, 2}, + {time.Second, time.Second + time.Millisecond, 0.002}, } for _, tc := range cases { @@ -1063,6 +1064,7 @@ func TestInEpsilon(t *testing.T) { {2.1, "bla-bla", 0}, {0.1, -0.1, 1.99}, {0, 0.1, 2}, // expected must be different to zero + {time.Second, time.Second + 10*time.Millisecond, 0.002}, } for _, tc := range cases {