From caec8fcc870267898597254ecf9705476ab42feb Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Wed, 28 Jan 2009 09:50:11 +0100 Subject: [PATCH] some more unit-tests for time-points --- test/test_cron.cpp | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-) 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 ///////////////////////////////////////////////////// -- 1.7.1