#include <time.h>
#include <stdlib.h>
+#include <stdexcept>
#include <cron.hpp>
CPPUNIT_TEST(Tomorrow);
CPPUNIT_TEST(NextWeek);
CPPUNIT_TEST(NextWeekFromToday);
+ CPPUNIT_TEST(StartMidnight);
+ CPPUNIT_TEST(StartMidnightTomorrow);
+ CPPUNIT_TEST(StartLastDaysec);
+ CPPUNIT_TEST(HalfOpenInterval);
// Intervals
CPPUNIT_TEST(IntervalBeginToday);
CPPUNIT_ASSERT_EQUAL( 1233532800, static_cast<int>(cron.get_next_run(1233100801)));
}
+ void StartMidnight()
+ {
+ WeekCron cron("2345",0);
+ CPPUNIT_ASSERT_EQUAL( 1233097200, static_cast<int>(cron.get_next_run(1233097199)));
+ }
+
+ void StartMidnightTomorrow()
+ {
+ WeekCron cron("2345",0);
+ CPPUNIT_ASSERT_EQUAL( 1233183600, static_cast<int>(cron.get_next_run(1233097200)));
+ }
+
+ void StartLastDaysec()
+ {
+ WeekCron cron("2345",86399);
+ CPPUNIT_ASSERT_EQUAL( 1233183599, static_cast<int>(cron.get_next_run(1233097200)));
+ }
+
+ void HalfOpenInterval()
+ {
+ WeekCron cron("2345",86400);
+ CPPUNIT_ASSERT_THROW(static_cast<int>(cron.get_next_run(1233097200)),std::runtime_error);
+ }
+
/////////////////////////////////////////////////////
// Intervals
/////////////////////////////////////////////////////