Skip to content

Commit

Permalink
Support uint in InDelta and InEpsilon
Browse files Browse the repository at this point in the history
InDelta and InEpsilon assertions on uint values would fail with
the error "Parameters must be numerical".
  • Loading branch information
dpw authored and boyan-soubachov committed Apr 29, 2020
1 parent 3bf8d0a commit ca8e08c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions assert/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,8 @@ func toFloat(x interface{}) (float64, bool) {
xok := true

switch xn := x.(type) {
case uint:
xf = float64(xn)
case uint8:
xf = float64(xn)
case uint16:
Expand Down
1 change: 1 addition & 0 deletions assert/assertions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,7 @@ func TestInDelta(t *testing.T) {
a, b interface{}
delta float64
}{
{uint(2), uint(1), 1},
{uint8(2), uint8(1), 1},
{uint16(2), uint16(1), 1},
{uint32(2), uint32(1), 1},
Expand Down

0 comments on commit ca8e08c

Please sign in to comment.