Maybe as a workaround you can use:

assertTrue("Expected 0.00, but was "+payment.getAmount(), payment.getAmount().compareTo(new BigInteger("0.00"));

(Alternativly you could define a convinience Method to compare BigDecimals)

You should always test the real contract, if the scale does not matter (so $1 == $1.00 == $1.0000000 ....) you should not use the equal Method to compare BigDecimals!

Am 06.07.2012 21:04, schrieb Mark:
Good question. We are trying to use JUnit to do things like:

assertThat(payment.getAmount(), is(new BigInteger("0.00")))

I can do something like:
assertTrue(payment.getAmount().compareTo(new BigInteger("0.00"));

But the team wanted the feed back that said "Expected 0.00, but was 5.00" instead of "Expected True, but was False."

I'll probably use the compareTo or setScale method. I just wanted to make sure there wasn't an easy way to get H2 and Oracle to return the same thing.

Thanks. I appreciate the feedback and suggestion.

Mark

On Friday, July 6, 2012 11:10:47 AM UTC-5, Christoph Läubrich wrote:

    Hi Mark,

    just wondering, why do you compare against a specific scale and not
    using the compareTo Method?
    
http://docs.oracle.com/javase/1.5.0/docs/api/java/math/BigDecimal.html#compareTo%28java.math.BigDecimal%29
    
<http://docs.oracle.com/javase/1.5.0/docs/api/java/math/BigDecimal.html#compareTo%28java.math.BigDecimal%29>

    This would be working with either 0 and 0.00 ...

--
You received this message because you are subscribed to the Google Groups "H2 Database" group. To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/_gb5roAuX7sJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.

--
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to