From 3d7b5f9a2a0e42d0e1a0179233dde8f7fe81c401 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Tue, 18 Mar 2008 03:13:52 +0000 Subject: [PATCH] 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 --- .../jackcess/DatabaseTest.java | 23 ++++++++++++++----- 1 file 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; + } } } } -- 2.39.5