Skip to content

Commit ca8e08c

Browse files
dpwboyan-soubachov
authored andcommitted
Support uint in InDelta and InEpsilon
InDelta and InEpsilon assertions on uint values would fail with the error "Parameters must be numerical".
1 parent 3bf8d0a commit ca8e08c

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

assert/assertions.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,8 @@ func toFloat(x interface{}) (float64, bool) {
11101110
xok := true
11111111

11121112
switch xn := x.(type) {
1113+
case uint:
1114+
xf = float64(xn)
11131115
case uint8:
11141116
xf = float64(xn)
11151117
case uint16:

assert/assertions_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,7 @@ func TestInDelta(t *testing.T) {
13061306
a, b interface{}
13071307
delta float64
13081308
}{
1309+
{uint(2), uint(1), 1},
13091310
{uint8(2), uint8(1), 1},
13101311
{uint16(2), uint16(1), 1},
13111312
{uint32(2), uint32(1), 1},

0 commit comments

Comments
 (0)