From: Thomas Jarosch Date: Wed, 28 Jan 2009 08:50:11 +0000 (+0100) Subject: some more unit-tests for time-points X-Git-Tag: v2.6~136^2~21 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=caec8fcc870267898597254ecf9705476ab42feb;p=libi2ncommon some more unit-tests for time-points --- diff --git a/test/test_cron.cpp b/test/test_cron.cpp index dbea5bb..532b1b3 100644 --- a/test/test_cron.cpp +++ b/test/test_cron.cpp @@ -13,6 +13,7 @@ #include #include +#include #include @@ -30,6 +31,10 @@ class TestCronFunc : public TestFixture 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); @@ -95,6 +100,30 @@ public: CPPUNIT_ASSERT_EQUAL( 1233532800, static_cast(cron.get_next_run(1233100801))); } + void StartMidnight() + { + WeekCron cron("2345",0); + CPPUNIT_ASSERT_EQUAL( 1233097200, static_cast(cron.get_next_run(1233097199))); + } + + void StartMidnightTomorrow() + { + WeekCron cron("2345",0); + CPPUNIT_ASSERT_EQUAL( 1233183600, static_cast(cron.get_next_run(1233097200))); + } + + void StartLastDaysec() + { + WeekCron cron("2345",86399); + CPPUNIT_ASSERT_EQUAL( 1233183599, static_cast(cron.get_next_run(1233097200))); + } + + void HalfOpenInterval() + { + WeekCron cron("2345",86400); + CPPUNIT_ASSERT_THROW(static_cast(cron.get_next_run(1233097200)),std::runtime_error); + } + ///////////////////////////////////////////////////// // Intervals /////////////////////////////////////////////////////