aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/src/cgeo/geocaching/utils/DateUtilsTest.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/src/cgeo/geocaching/utils/DateUtilsTest.java b/tests/src/cgeo/geocaching/utils/DateUtilsTest.java
index 0a9d3e3..f82225a 100644
--- a/tests/src/cgeo/geocaching/utils/DateUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/DateUtilsTest.java
@@ -1,5 +1,8 @@
package cgeo.geocaching.utils;
+import cgeo.geocaching.Geocache;
+import cgeo.geocaching.enumerations.CacheType;
+
import java.util.Calendar;
import junit.framework.TestCase;
@@ -14,4 +17,25 @@ public class DateUtilsTest extends TestCase {
}
}
+ public static void testIsPastEvent() {
+ final Calendar start = Calendar.getInstance();
+ start.set(Calendar.HOUR_OF_DAY, 0);
+ start.set(Calendar.MINUTE, 10);
+ assertPastEvent(start, false);
+
+ start.set(Calendar.HOUR_OF_DAY, 23);
+ assertPastEvent(start, false);
+
+ start.add(Calendar.DAY_OF_MONTH, -1);
+ assertPastEvent(start, true);
+ }
+
+ private static void assertPastEvent(final Calendar start, boolean expectedPast) {
+ final Geocache cache = new Geocache();
+ cache.setType(CacheType.EVENT);
+
+ cache.setHidden(start.getTime());
+ assertEquals(expectedPast, DateUtils.isPastEvent(cache));
+ }
+
}