]> source.dussan.org Git - iciql.git/commitdiff
Relax BigDecimal equivalency checks
authorJames Moger <james.moger@gitblit.com>
Sat, 1 Nov 2014 15:55:23 +0000 (11:55 -0400)
committerJames Moger <james.moger@gitblit.com>
Mon, 3 Nov 2014 17:51:16 +0000 (12:51 -0500)
src/test/java/com/iciql/test/SamplesTest.java
src/test/java/com/iciql/test/models/SupportedTypes.java

index df6d219deaef6e183cbdf51bc53dceac78cb6613..dbbf97fa2061b6586ff3f48c0e04ede74b6500bf 100644 (file)
@@ -28,6 +28,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;\r
 \r
 import java.math.BigDecimal;\r
+import java.text.DecimalFormat;\r
 import java.util.Collections;\r
 import java.util.HashSet;\r
 import java.util.List;\r
@@ -214,7 +215,7 @@ public class SamplesTest {
 \r
                @Override\r
                public String toString() {\r
-                       return customerId + ":" + orderId + ":" + total;\r
+                       return customerId + ":" + orderId + ":" + new DecimalFormat("##.00").format(total);\r
                }\r
        }\r
 \r
index 489650e841a7815b38f46b95e0cffca0846387fa..d9a640560111f0ef76c7c4d356f089b2fb906f5a 100644 (file)
@@ -19,6 +19,7 @@ package com.iciql.test.models;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.math.MathContext;
 import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
@@ -178,7 +179,10 @@ public class SupportedTypes implements Serializable {
                same &= same("myLong", myLong.equals(s.myLong));
                same &= same("myFloat", IciqlSuite.equivalentTo(myFloat, s.myFloat));
                same &= same("myDouble", IciqlSuite.equivalentTo(myDouble, s.myDouble));
-               same &= same("myBigDecimal", myBigDecimal.compareTo(s.myBigDecimal) == 0);
+
+               BigDecimal bda = myBigDecimal.round(MathContext.DECIMAL32);
+               BigDecimal bdb = s.myBigDecimal.round(MathContext.DECIMAL32);
+               same &= same("myBigDecimal", bda.compareTo(bdb) == 0);
 
                SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                same &= same("myUtilDate", df.format(myUtilDate).equals(df.format(s.myUtilDate)));