Skip to content

Commit

Permalink
dird: add comparison operators to SchedulerJobItem
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Nov 21, 2019
1 parent b8748e2 commit 485791e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/src/dird/scheduler_job_item_queue.h
Expand Up @@ -43,6 +43,13 @@ struct SchedulerJobItem {
{
is_valid = job && runtime;
};
bool operator==(const SchedulerJobItem& rhs) const
{
return runtime == rhs.runtime && job == rhs.job &&
priority == rhs.priority && run == rhs.run;
}
bool operator!=(const SchedulerJobItem& rhs) const { return !(*this == rhs); }

JobResource* job{nullptr};
RunResource* run{nullptr};
time_t runtime{0};
Expand Down
13 changes: 13 additions & 0 deletions core/src/tests/scheduler_job_item_queue.cc
Expand Up @@ -42,6 +42,19 @@ TEST(scheduler_job_item_queue, job_item)
EXPECT_TRUE(item_unitialised.is_valid);
}

TEST(scheduler_job_item_queue, compare_job_items)
{
JobResource job[2];
RunResource run[2];

SchedulerJobItem item1(&job[0], &run[0], time(nullptr), 10);
SchedulerJobItem item2 = item1;
SchedulerJobItem item3(&job[1], &run[1], time(nullptr) + 3600, 11);

EXPECT_EQ(item1, item2);
EXPECT_NE(item1, item3);
}

TEST(scheduler_job_item_queue, priority_and_time)
{
time_t now = time(nullptr);
Expand Down

0 comments on commit 485791e

Please sign in to comment.