time.Duraions are numbers too

pull/475/head^2
Joshua T Corbin 2017-07-13 09:59:43 -07:00 committed by Davide D'Agostino
parent b1f989447a
commit 2f1cd6b778
2 changed files with 4 additions and 0 deletions

View File

@ -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
}

View File

@ -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 {