diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2008-03-18 03:13:52 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2008-03-18 03:13:52 +0000 |
commit | 3d7b5f9a2a0e42d0e1a0179233dde8f7fe81c401 (patch) | |
tree | c22c1af2752a3548a585670dcdb86f28862b7ba4 | |
parent | 8f8d0c0756b4f483ddf1022743387c65d0769d1d (diff) | |
download | jackcess-3d7b5f9a2a0e42d0e1a0179233dde8f7fe81c401.tar.gz jackcess-3d7b5f9a2a0e42d0e1a0179233dde8f7fe81c401.zip |
be little lenient in date assertions due to double rounding
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@280 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r-- | test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java index 814e162..a8c77fa 100644 --- a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java @@ -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; + } } } } |