Re: Re: Asserts using Comparable.compareTo() instead of equals() (for BigDecimal and others)
<[email protected]> 17 Mar 2014 23:39:31 -0700
| Newsgroups | gmane.comp.java.junit.user |
|---|---|
| Message-ID | <[email protected]> |
Thank you for clarifying. To clear up my point, I wasn't saying that there wasn't a way to to compare BigDecimals, I was saying that there isn't a way to do it that ships with Junit. There are hamcrest Matchers that ship with JUnit, and there are hamcrest Matchers that handle BigDecimal comparisons well, but none of those ship with JUnit. Given how heavily BigDecimal is used, and how standard it is, I feel that JUnit should ship with Matchers that can handle it. (I've even found a Matcher class that is in a package that ships with JUnit, but the Matcher class itself does not!) Incidentally, our tests deliberately use BigDecimals with different scales, to ensure our software handles them (and compares them) properly. Your application may not need this, but I'm sure you can see the wisdom in it.