From: Gerd von Egidy Date: Fri, 3 Apr 2009 15:58:15 +0000 (+0200) Subject: fix unit-tests - the results were ok for the new code, remove debugging-output X-Git-Tag: v2.6~127^2 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=640044242c79b785428b4eff41d2770e8691d89b;p=libi2ncommon fix unit-tests - the results were ok for the new code, remove debugging-output --- diff --git a/src/cron.cpp b/src/cron.cpp index 86cdbd7..2d9b8a0 100644 --- a/src/cron.cpp +++ b/src/cron.cpp @@ -136,21 +136,16 @@ time_t WeekCron::get_next_run(time_t calc_from) const { // interval time_t next_begin = get_next_point(calc_from,Begin,true); -std::cerr << "next_begin = " << next_begin << std::endl; -std::cerr << "next_end = " << get_next_point(calc_from,End-1,true) << std::endl; if (next_begin > get_next_point(calc_from,End-1,true)) { // next begin > next end means we are at the begin or within the interval time_t interval_begin=get_previousnow_point(calc_from,Begin,true); -std::cerr << "interval_begin = " << interval_begin << std::endl; time_t within_interval=calc_from - interval_begin; time_t since_lastrun=within_interval % Every; time_t next_exec=calc_from+(Every-since_lastrun); -std::cerr << "next_exec = " << next_exec << std::endl; - // next step at or after end? if (next_exec > get_next_point(calc_from,End-1,true)) return get_next_point(calc_from,Begin,true); diff --git a/test/test_cron_interval.cpp b/test/test_cron_interval.cpp index f39b0b0..02b6cb7 100644 --- a/test/test_cron_interval.cpp +++ b/test/test_cron_interval.cpp @@ -60,8 +60,6 @@ class TestCronIntervalFunc : public TestFixture CPPUNIT_TEST(IntervalInSecondDSTBackwards2); CPPUNIT_TEST(IntervalOutFirstDSTBackwards1); CPPUNIT_TEST(IntervalOutFirstDSTBackwards2); - CPPUNIT_TEST(IntervalOutFirstDSTBackwards3); - CPPUNIT_TEST(IntervalOutFirstDSTBackwards4); CPPUNIT_TEST(IntervalOutSecondDSTBackwards1); CPPUNIT_TEST(IntervalDSTBackwardsWholeday1); CPPUNIT_TEST(IntervalDSTBackwardsWholeday2); @@ -304,33 +302,14 @@ public: void IntervalOutFirstDSTBackwards1() { - // FIXME: is Sun Oct 26 02:30:00 CET 2008 WeekCron cron("0123456",9000,18000,60); // calc at: Sun Oct 26 02:29:00 CEST 2008 - // expected next run: Sun Oct 26 02:30:00 CEST 2008 - CPPUNIT_ASSERT_EQUAL( static_cast(1224981000), cron.get_next_run(1224980940)); + // expected next run: Sun Oct 26 02:30:00 CET 2008 + CPPUNIT_ASSERT_EQUAL( static_cast(1224984600), cron.get_next_run(1224980940)); } void IntervalOutFirstDSTBackwards2() { - // FIXME: is Sun Oct 26 02:30:00 CET 2008 - WeekCron cron("0123456",9000,18000,60); - // calc at: Sun Oct 26 02:30:00 CEST 2008 - // expected next run: Sun Oct 26 02:31:00 CEST 2008 - CPPUNIT_ASSERT_EQUAL( static_cast(1224981060), cron.get_next_run(1224981000)); - } - - void IntervalOutFirstDSTBackwards3() - { - // FIXME: is Sun Oct 26 02:30:00 CET 2008 - WeekCron cron("0123456",9000,18000,60); - // calc at: Sun Oct 26 02:59:59 CEST 2008 - // expected next run: Sun Oct 26 02:00:00 CET 2008 - CPPUNIT_ASSERT_EQUAL( static_cast(1224982800), cron.get_next_run(1224982799)); - } - - void IntervalOutFirstDSTBackwards4() - { WeekCron cron("0123456",9000,18000,60); // calc at: Sun Oct 26 02:29:00 CET 2008 // expected next run: Sun Oct 26 02:30:00 CET 2008 diff --git a/test/test_cron_point.cpp b/test/test_cron_point.cpp index 214c28f..047ce13 100644 --- a/test/test_cron_point.cpp +++ b/test/test_cron_point.cpp @@ -333,15 +333,22 @@ public: bool conversion_ok = (localtime_r(&result, &calc_daybegin) != NULL); CPPUNIT_ASSERT_EQUAL(true, conversion_ok); - calc_daybegin.tm_hour=0; - calc_daybegin.tm_min=0; - calc_daybegin.tm_sec=0; + int remain=daysec; + + calc_daybegin.tm_hour=remain/3600; + remain-=calc_daybegin.tm_hour*3600; + + calc_daybegin.tm_min=remain/60; + remain-=calc_daybegin.tm_min*60; + + calc_daybegin.tm_sec=remain; + // tm_isdst=-1 means to use the dst in use at the given time calc_daybegin.tm_isdst=-1; - time_t daybegin = mktime(&calc_daybegin); + time_t daytime = mktime(&calc_daybegin); - CPPUNIT_ASSERT_EQUAL(daybegin + daysec, result); + CPPUNIT_ASSERT_EQUAL(daytime, result); } } };