IsCloseTo matcher should operate on Number rather than Double#184
IsCloseTo matcher should operate on Number rather than Double#184mrpotes wants to merge 2 commits intohamcrest:masterfrom
Conversation
|
Interesting. So the use case is that you have a collection of mixed numbers, some of which are floating point and some not? |
|
Actually, IIRC I had a long, and wanted to do a close-to check, but it wouldn't work because number wasn't a double. |
|
In that case, it makes more sense to me to have an ordinal version of close to. It feels odd to do floating point comparisons for int/long. |
|
I don't disagree with that as also desirable, but if you consider, for example, a number that is being parsed from JSON, you may not know what the eventual type is going to be (JSON not distinguishing between ordinal and floating point numbers), so it is still useful to have the floating point version deal with Number so that if a JSON field had either |
|
Good point |
|
@mrpotes wanting to kick start open pr's, can you rebase from master, as |
|
Going to try and kick start hamcrest, so if you want to get it merged, please rebase from the branch |
9bc653b to
e9f7fc8
Compare
The
IsCloseTo/closeTomatcher should be able to check all numerical types are within the bounds set, rather than just doubles. The implementation already worked if a primitive value was cast todouble, but did not work in the case of boxed non-Double numbers, e.g. when trying to check Integer values in a list or map, etc.