Java 8 RFR 8022094: BigDecimal/CompareToTests and BigInteger/CompareToTests are incorrect

Stuart Marks stuart.marks at
Fri Aug 2 02:54:11 UTC 2013

Looks good. Always a good idea to make sure that failures are reported 
properly. :-)

It does look like the following cases are repeated, in both tests:

     {valueOf(Long.MIN_VALUE+1),          valueOf(Long.MAX_VALUE), MINUS_ONE},
     {valueOf(Long.MIN_VALUE+1).negate(), valueOf(Long.MAX_VALUE), ZERO},

Is this right?

The first four cases are (excuse the poor cross product notation):

     {max, max-1, min, min+1} x {1, -1} compareTo max

but then there's simply

     {min} x {1, -1} compareTo min

followed by the duplicate

     {min+1} x {1, -1} compareTo max

Just following the pattern, I'd expect

     {max, max-1, min, min+1} x {1, -1} compareTo min

though I'm not sure that all of these cases are necessary.


On 8/1/13 12:09 PM, Brian Burkhalter wrote:
> Reviewers:
> This is a test-only issue.
> Issue (not public quite yet)
> Webrev
> Summary:
> 1) BigDecimal
> * The compareToTest() method was modified to correctly print and report errors.
> * The set of test cases was changed to eliminate incorrect assumptions.
> 2) BigInteger
> * Old version replaced by copying BigDecimal version and changing BigDecimal to BigInteger.
> * Fractional test cases were replace with others to probe internal mag array having different relative lengths.
> Thanks,
> Brian

More information about the core-libs-dev mailing list