]> WPIA git - gigi.git/blobdiff - tests/org/cacert/gigi/TestCalendarUtil.java
Merge "Suggestions to enhance the SQL call pattern."
[gigi.git] / tests / org / cacert / gigi / TestCalendarUtil.java
index 87da1b05d6c36ead2353b793c9be82726b17caa5..47ce3b99d5c8570997e09c69ce34bacd965c9f87 100644 (file)
@@ -33,6 +33,29 @@ public class TestCalendarUtil {
 
     }
 
+    @Test
+    public void testIsOfAge() {
+
+        Calendar now = Calendar.getInstance();
+        int year = now.get(Calendar.YEAR);
+        int month = now.get(Calendar.MONTH) + 1;
+        int days = now.get(Calendar.DATE);
+
+        DayDate dob = CalendarUtil.getDateFromComponents(year - 14, month, days);
+
+        assertTrue(CalendarUtil.isOfAge(dob, 13));
+
+        assertTrue(CalendarUtil.isOfAge(dob, 14));
+
+        dob = CalendarUtil.getDateFromComponents(year - 14, month, days + 1);
+        assertFalse(CalendarUtil.isOfAge(dob, 14));
+
+    }
+
+    static {
+        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+    }
+
     @Test
     public void testIsDateValid() {
         assertTrue(CalendarUtil.isDateValid(2016, 2, 28));