assert: accept values with named types in InDelta*
, InEpsilon*
#1492
Labels
assert.InEpsilon
About assert.InEpsilon and family
enhancement
pkg-assert
Change related to package testify/assert
pkg-require
Change related to package testify/require
Milestone
Issue
The function
toFloat
converts into afloat64
allint
,uint
andfloat
types. However,toFloat
does not support conversion from a type whose underlying type is one of those accepted types. Consider for exampleand therefore some assertions may fail such as
who fails with message
Parameters must be numerical
. The user is then forced to cast the input valuesInDelta
/InEpsilon
for a type derived fromfloat64
.Question
Would it be desirable to allow
toFloat
to recognise types derived from any of the currently accepted types?Suggestion
Consideration
Performance must be considered. Two successive switch-case blocks (the first one not using reflection) may be of interest to retain high performance for cases where the type received is directly numerical (and not just derived from a numerical type).
The text was updated successfully, but these errors were encountered: