mirror of
https://github.com/PerMalmberg/libcron.git
synced 2025-07-24 19:23:18 -05:00
Added LocalClock.
This commit is contained in:
@@ -16,7 +16,7 @@ system_clock::time_point DT(year_month_day ymd, hours h = hours{0}, minutes m =
|
||||
}
|
||||
|
||||
bool test(const std::string& schedule, system_clock::time_point from,
|
||||
std::vector<system_clock::time_point> expected_next)
|
||||
const std::vector<system_clock::time_point>& expected_next)
|
||||
{
|
||||
auto c = CronData::create(schedule);
|
||||
bool res = c.is_valid();
|
||||
@@ -209,22 +209,6 @@ SCENARIO("Examples from README.md")
|
||||
}));
|
||||
}
|
||||
|
||||
//SCENARIO("Daylight Savings Time")
|
||||
//{
|
||||
// // In sweden when local standard time is about to reach
|
||||
// //Sunday, 25 March 2018, 02:00:00 clocks are turned forward 1 hour to
|
||||
// //Sunday, 25 March 2018, 03:00:00 local daylight time instead.
|
||||
//
|
||||
// REQUIRE(test("0 0 * * * ?", DT(2018_y / 3 / 25, hours{0}),
|
||||
// {
|
||||
// DT(2018_y / 3 / 25, hours{0}),
|
||||
// DT(2018_y / 3 / 25, hours{1}),
|
||||
// // This hour disappear! DT(2018_y / 3 / 25, hours{2}),
|
||||
// DT(2018_y / 3 / 25, hours{3}),
|
||||
// DT(2018_y / 3 / 25, hours{4})
|
||||
// }));
|
||||
//}
|
||||
|
||||
SCENARIO("Unable to calculate time point")
|
||||
{
|
||||
// TODO: Find a schedule that is unsolvable.
|
||||
|
@@ -6,9 +6,9 @@
|
||||
using namespace libcron;
|
||||
using namespace std::chrono;
|
||||
|
||||
std::string create_schedule_expiring_in(hours h, minutes m, seconds s)
|
||||
std::string create_schedule_expiring_in(std::shared_ptr<ICronClock> clock, hours h, minutes m, seconds s)
|
||||
{
|
||||
auto now = system_clock::now() + h + m + s;
|
||||
auto now = clock->now() + h + m + s;
|
||||
auto dt = CronSchedule::to_calendar_time(now);
|
||||
|
||||
std::string res{};
|
||||
@@ -66,7 +66,7 @@ SCENARIO("Adding a task that expires in the future")
|
||||
auto expired = false;
|
||||
|
||||
Cron c;
|
||||
REQUIRE(c.add_schedule("A task", create_schedule_expiring_in(hours{0}, minutes{0}, seconds{3}),
|
||||
REQUIRE(c.add_schedule("A task", create_schedule_expiring_in(c.get_clock(), hours{0}, minutes{0}, seconds{3}),
|
||||
[&expired]()
|
||||
{
|
||||
expired = true;
|
||||
@@ -107,14 +107,14 @@ SCENARIO("Task priority")
|
||||
|
||||
|
||||
Cron c;
|
||||
REQUIRE(c.add_schedule("Five", create_schedule_expiring_in(hours{0}, minutes{0}, seconds{5}),
|
||||
REQUIRE(c.add_schedule("Five", create_schedule_expiring_in(c.get_clock(), hours{0}, minutes{0}, seconds{5}),
|
||||
[&_5_second_expired]()
|
||||
{
|
||||
_5_second_expired++;
|
||||
})
|
||||
);
|
||||
|
||||
REQUIRE(c.add_schedule("Three", create_schedule_expiring_in(hours{0}, minutes{0}, seconds{3}),
|
||||
REQUIRE(c.add_schedule("Three", create_schedule_expiring_in(c.get_clock(), hours{0}, minutes{0}, seconds{3}),
|
||||
[&_3_second_expired]()
|
||||
{
|
||||
_3_second_expired++;
|
||||
|
Reference in New Issue
Block a user