Logo Search packages:      
Sourcecode: pcalendar version File versions  Download package

void net::sf::linuxorg::pcal::engine::EngineTest::testGetDayInfo (  ) [inline]

Test method for net.sf.linuxorg.pcal.engine.Engine#getDayInfo(java.util.Date).

Definition at line 95 of file EngineTest.java.

References net::sf::linuxorg::pcal::PCalDayInfo::day_num, net::sf::linuxorg::pcal::PCalDayInfo::estimate, and net::sf::linuxorg::pcal::engine::Engine::getDayInfo().

Referenced by testEncryptedLoadSave(), testImportExport(), and testLoadSave().

                                   {
            PCalDayInfo dayInfo;

            // test prehistoric dates edge case
            calendar.set(1980, 9, 26);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertNull(dayInfo);

            // test day 1 combinations
            // recorded day 0
            calendar.set(2007, 9, 26);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 0);
            assertFalse(dayInfo.estimate);
            assertFalse(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertTrue(dayInfo.badFeel);
            assertFalse(dayInfo.ovulation);

            // estimated day 0
            calendar.set(2008, 1, 3);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 0);
            assertTrue(dayInfo.estimate);
            assertFalse(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertTrue(dayInfo.badFeel);
            assertFalse(dayInfo.ovulation);

            // test fertile days combinations
            calendar.set(2007, 9, 12);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 11);
            assertFalse(dayInfo.estimate);
            assertTrue(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.ovulation);

            calendar.set(2008, 0, 19);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 10);
            assertTrue(dayInfo.estimate);
            assertTrue(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.ovulation);

            // test non-fertile days combinations
            calendar.set(2007, 10, 25);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 5);
            assertFalse(dayInfo.estimate);
            assertFalse(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.ovulation);

            calendar.set(2008, 0, 11);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 2);
            assertTrue(dayInfo.estimate);
            assertFalse(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.ovulation);

            // test pregnancy days combinations
            calendar.set(2008, 6, 2);
            Date date = calendar.getTime();
            engine.addPregnancyDate(date);

            calendar.set(2009, 3, 6);

            // estimated pregnancy date
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 278);
            assertTrue(dayInfo.estimate);
            assertFalse(dayInfo.fertile);
            assertTrue(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertTrue(dayInfo.badFeel);
            assertFalse(dayInfo.ovulation);

            // estimated birth date
            calendar.set(2009, 3, 8);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 0);
            assertTrue(dayInfo.estimate);
            assertFalse(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.pregnancy_interruption);
            assertTrue(dayInfo.birth);
            assertTrue(dayInfo.badFeel);
            assertFalse(dayInfo.ovulation);

            engine.addBirthDate(calendar.getTime());

            // recorded birth
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 0);
            assertFalse(dayInfo.estimate);
            assertFalse(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.pregnancy_interruption);
            assertTrue(dayInfo.birth);
            assertTrue(dayInfo.badFeel);
            assertFalse(dayInfo.ovulation);

            // recorded pregnancy
            calendar.set(2009, 3, 6);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 278);
            assertFalse(dayInfo.estimate);
            assertFalse(dayInfo.fertile);
            assertTrue(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertTrue(dayInfo.badFeel);
            assertFalse(dayInfo.ovulation);

            // test the interrupted pregnancy functionality
            calendar.set(2009, 3, 8);
            engine.removeDateRecord(calendar.getTime());

            calendar.set(2009, 3, 6);
            engine.addPregnancyInterruptDate(calendar.getTime());

            // interruption date
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 0);
            assertFalse(dayInfo.estimate);
            assertFalse(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertTrue(dayInfo.pregnancy_interruption);
            assertTrue(dayInfo.badFeel);
            assertFalse(dayInfo.ovulation);

            // after interruption
            calendar.set(2009, 3, 7);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, -1);
            assertTrue(dayInfo.estimate);
            assertFalse(dayInfo.fertile);
            assertFalse(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertFalse(dayInfo.badFeel);
            assertFalse(dayInfo.ovulation);

            // before interruption
            calendar.set(2009, 3, 5);
            dayInfo = engine.getDayInfo(calendar.getTime());
            assertEquals(dayInfo.day_num, 277);
            assertFalse(dayInfo.estimate);
            assertFalse(dayInfo.fertile);
            assertTrue(dayInfo.pregnancy);
            assertFalse(dayInfo.birth);
            assertFalse(dayInfo.pregnancy_interruption);
            assertTrue(dayInfo.badFeel);
            assertFalse(dayInfo.ovulation);

            // test the empty dataset case
            engine.newFile();
            assertNull(engine.getDayInfo(calendar.getTime()));

            calendar.set(2007, 9, 1);
            engine.addStartDate(calendar.getTime());
            calendar.set(2007, 9, 5);
            assertNull(engine.getDayInfo(calendar.getTime()));

      }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index