mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-13 03:32:28 -04:00
Core/EventMap: Clarify documentation of ScheduleEvent
(cherry picked from commit 7865c1c197)
This commit is contained in:
@@ -115,7 +115,7 @@ public:
|
||||
|
||||
/**
|
||||
* @name ScheduleEvent
|
||||
* @brief Schedules a new event.
|
||||
* @brief Schedules a new event. An existing event is not canceled.
|
||||
* @param eventId The id of the new event.
|
||||
* @param time The time until the event occurs as std::chrono type.
|
||||
* @param group The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
|
||||
/**
|
||||
* @name ScheduleEvent
|
||||
* @brief Schedules a new event.
|
||||
* @brief Schedules a new event. An existing event is not canceled.
|
||||
* @param eventId The id of the new event.
|
||||
* @param minTime The minimum time until the event occurs as std::chrono type.
|
||||
* @param maxTime The maximum time until the event occurs as std::chrono type.
|
||||
|
||||
@@ -77,21 +77,40 @@ TEST_CASE("Schedule an event", "[EventMap]")
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: The semantics of this case are not well defined.
|
||||
// Document them first, check consumers and adapt test
|
||||
// accordingly.
|
||||
TEST_CASE("Schedule existing event", "[EventMap][!mayfail]")
|
||||
TEST_CASE("Schedule existing event", "[EventMap]")
|
||||
{
|
||||
EventMap eventMap;
|
||||
|
||||
eventMap.ScheduleEvent(EVENT_1, 1s);
|
||||
eventMap.ScheduleEvent(EVENT_1, 1s);
|
||||
SECTION("Same time")
|
||||
{
|
||||
eventMap.ScheduleEvent(EVENT_1, 1s);
|
||||
eventMap.ScheduleEvent(EVENT_1, 1s);
|
||||
|
||||
eventMap.Update(1000);
|
||||
uint32 id = eventMap.ExecuteEvent();
|
||||
eventMap.Update(1000);
|
||||
uint32 id = eventMap.ExecuteEvent();
|
||||
REQUIRE(id == EVENT_1);
|
||||
|
||||
REQUIRE(id == EVENT_1);
|
||||
REQUIRE(eventMap.Empty());
|
||||
id = eventMap.ExecuteEvent();
|
||||
REQUIRE(id == EVENT_1);
|
||||
|
||||
REQUIRE(eventMap.Empty());
|
||||
}
|
||||
|
||||
SECTION("Different time")
|
||||
{
|
||||
eventMap.ScheduleEvent(EVENT_1, 1s);
|
||||
eventMap.ScheduleEvent(EVENT_1, 2s);
|
||||
|
||||
eventMap.Update(1000);
|
||||
uint32 id = eventMap.ExecuteEvent();
|
||||
REQUIRE(id == EVENT_1);
|
||||
|
||||
eventMap.Update(1000);
|
||||
id = eventMap.ExecuteEvent();
|
||||
REQUIRE(id == EVENT_1);
|
||||
|
||||
REQUIRE(eventMap.Empty());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Cancel a scheduled event", "[EventMap]")
|
||||
|
||||
Reference in New Issue
Block a user