diff --git a/src/test/java/htsjdk/samtools/util/RelativeIso8601DateTest.java b/src/test/java/htsjdk/samtools/util/RelativeIso8601DateTest.java index 4fa56d577e..e4e9ef9932 100644 --- a/src/test/java/htsjdk/samtools/util/RelativeIso8601DateTest.java +++ b/src/test/java/htsjdk/samtools/util/RelativeIso8601DateTest.java @@ -10,13 +10,17 @@ /** @author mccowan */ public class RelativeIso8601DateTest { + + // 1 second resolution is ISO date + private final static double DELTA_FOR_TIME = 1000; + @Test public void testLazyInstance() { final RelativeIso8601Date lazy = RelativeIso8601Date.generateLazyNowInstance(); Assert.assertEquals(lazy.toString(), RelativeIso8601Date.LAZY_NOW_LABEL); Assert.assertEquals(lazy.toString(), RelativeIso8601Date.LAZY_NOW_LABEL); Assert.assertEquals(lazy.toString(), RelativeIso8601Date.LAZY_NOW_LABEL); - Assert.assertEquals(lazy.getTime(), new Iso8601Date(new Date(System.currentTimeMillis())).getTime(), 1000); // 1 second resolution is ISO date + Assert.assertEquals(lazy.getTime(), new Iso8601Date(new Date(System.currentTimeMillis())).getTime(), DELTA_FOR_TIME); // Assert no exception thrown; this should be valid, because toString should now return an iso-looking date. new Iso8601Date(lazy.toString()); } @@ -33,7 +37,7 @@ public void testNonLazyInstance() { for (final RelativeIso8601Date nonLazy : testDates) { Assert.assertFalse(nonLazy.toString().equals(RelativeIso8601Date.LAZY_NOW_LABEL)); - Assert.assertEquals((double) nonLazy.getTime(), (double) time); + Assert.assertEquals((double) nonLazy.getTime(), (double) time, DELTA_FOR_TIME); // Assert no exception thrown; this should be valid, because toString return an iso-looking date. new RelativeIso8601Date(nonLazy.toString()); } @@ -44,6 +48,6 @@ public void equalityTest() { final String s = new Iso8601Date(new Date(12345)).toString(); final Iso8601Date iso8601Date = new Iso8601Date(s); final RelativeIso8601Date relativeIso8601Date = new RelativeIso8601Date(s); - Assert.assertEquals(relativeIso8601Date.getTime(), iso8601Date.getTime()); + Assert.assertEquals(relativeIso8601Date.getTime(), iso8601Date.getTime(), DELTA_FOR_TIME); } }