]> WPIA git - gigi.git/blobdiff - tests/org/cacert/gigi/TestCalendarUtil.java
move of-age-test to calendar util
[gigi.git] / tests / org / cacert / gigi / TestCalendarUtil.java
index 87da1b05d6c36ead2353b793c9be82726b17caa5..0ab6abb4aebd8b4aa530e4e3b54641db8d36bef5 100644 (file)
@@ -33,6 +33,25 @@ 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));
+
+    }
+
     @Test
     public void testIsDateValid() {
         assertTrue(CalendarUtil.isDateValid(2016, 2, 28));