]> source.dussan.org Git - jackcess.git/commitdiff
be little lenient in date assertions due to double rounding
authorJames Ahlborn <jtahlborn@yahoo.com>
Tue, 18 Mar 2008 03:13:52 +0000 (03:13 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Tue, 18 Mar 2008 03:13:52 +0000 (03:13 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@280 f203690c-595d-4dc9-a70b-905162fa7fd2

test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java

index 814e1622b591c96083d970451acac713fd01f2e3..a8c77fa978776e940571ac680dfdb75edf6f001f 100644 (file)
@@ -789,12 +789,23 @@ public class DatabaseTest extends TestCase {
 
     assertEquals(dates.size(), foundDates.size());
     for(int i = 0; i < dates.size(); ++i) {
-      try {
-        assertEquals(dates.get(i), foundDates.get(i));
-      } catch(Error e) {
-        System.err.println("Expected " + dates.get(i).getTime() + ", found " +
-                           foundDates.get(i).getTime());
-        throw e;
+      Date expected = dates.get(i);
+      Date found = foundDates.get(i);
+      if(expected == null) {
+        assertNull(found);
+      } else {
+        // there are some rounding issues due to dates being stored as
+        // doubles, but it results in a 1 millisecond difference, so i'm not
+        // going to worry about it
+        long expTime = expected.getTime();
+        long foundTime = found.getTime();
+        try {
+          assertTrue((expTime == foundTime) ||
+                     (Math.abs(expTime - foundTime) <= 1));
+        } catch(Error e) {
+          System.err.println("Expected " + expTime + ", found " + foundTime);
+          throw e;
+        }
       }
     }
   }